Symfony cache in ullright
Warning: do not use the cache with enabled "legacy mobile version". It will mix up desktop and mobile version.
Enabling cache
apps/frontend/config/settings.yml
prod: .settings: cache: true dev: .settings: # Set this true for debugging !!! cache: false
Enable conditional cache filter for ullCms/show
apps/frontend/config/filters.yml
... i18n: class: i18nFilter conditionalCache: class: conditionalCacheFilter param: pages: - { module: ullCms, action: show } cache: ~ ...
Remove all for an action
Sadly sfCache does not support a method to clear all cached variants of an module/action.
Workaround:
// NOTE: if there is no chache manager, make sure cache is enabled in settings.yml! if ($cacheManager = sfContext::getInstance()->getViewCacheManager()) { $cacheDir = $cacheManager->getCache()->getOption('cache_dir'); $cacheKey = $cacheManager->generateCacheKey('ullCms/show'); $path = $cacheDir . $cacheKey; sfToolkit::clearDirectory($path); }
Dev info:
http://symfony.com/legacy/doc/gentle-introduction/1_4/en/12-Caching
type = sfFileCache
File / Function Cache:
public static function doSomethingCached($param) { $cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_cache_dir').'/function', 'lifetime' => 60*60*24)); $fc = new sfFunctionCache($cache); return $fc->call( array('myClass', 'myMethod'), array($param)); }