Skip to content

Instantly share code, notes, and snippets.

@ivoba
Created July 10, 2012 10:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivoba/3082497 to your computer and use it in GitHub Desktop.
Save ivoba/3082497 to your computer and use it in GitHub Desktop.
symfony2 caching data via doctrine/commons
$cache = $this->get('cache');
$cache->setNamespace('mynamespace.cache');
if (false === ($cached_data = $cache->fetch($cache_key))) {
$cached_data = $SOMEAPI->getData($params);
$cache->save($cache_key, $cached_data, 3600);//TTL 1h
}
cache:
class: Doctrine\Common\Cache\PhpFileCache
arguments: [%kernel.cache_dir%]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment