sfManagedCachePlugin

The rough plugin for Symfony is done, albeit not published yet. Usage is very similar to the sfFunctionCache class, and it comes with the appropriate tasks to refresh/clear cached items.

Usage example:

$sfManagedCache = new sfManagedFunctionCache(
  new sfFileCache(array(
    'cache_dir' => sfConfig::get('sf_external_cache_dir').'/sfManagedCache',
    'lifetime' => 86400))
);

$xml = $sfManagedCache->call(
  array('Webserice', 'call''),
  array($parameter1, $parameter2),
  1800
);

The tasks are used like this and should be set up as cron jobs:

./symfony managed_cache:refresh --application=webservice --env=prod
./symfony managed_cache:refresh --env=prod

The first call is for a specific application while the second one is for application-agnostic cache items (not for all items!).

This is not a fire-and-forget plugin. It requires planning and maintenance. Since the cached items are designed to never expire, carelessness can easily lead to problems. I will cleanup the plugin some more, write documentation and then release it.

Leave a comment

Your comment