Cache management with events

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Cache management with events

Norbert Máté
Hi everybody,
  I am working on a site that uses no caching yet and I want to introduce
memcached to the project. The site is a social network site, it has posts,
likes, shares, comments...I am thinking about how to add caching without
modifying every single controller to add/update things in the cache.
   I think I should use aspect oriented programing. Create a module that
checks the requests and updates the cache if needed. The problem with this
is that the cache has to be updated after the database is updated. For
example if someone posts something I would need the post id to be able to
add the post to memcached. So this solution won't work.
   The second solution I am thinking about is to have a module that listens
to all kind of events (post saved, post updated...) and manages the cache
this way.

Do you have a better solution? What if I will have 100 of events, will the
event manager work well with many events too?

Regards,
Norbert.