Created
March 6, 2012 17:47
-
-
Save peterjmit/1987713 to your computer and use it in GitHub Desktop.
Revisions
-
peterjmit revised this gist
Mar 6, 2012 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,4 +31,8 @@ public function saveToCache($item_to_save) { $this->getCacheDriver()->save('foo_key', $item_to_save); } } $foo = new Foo($doctrine_entity_manager); $foo->saveToCache('bar'); -
peterjmit revised this gist
Mar 6, 2012 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,6 +23,10 @@ public function getCacheDriver() return $this->_em->getConfiguration()->getResultCacheImpl(); } /** * Example usage of Foo::getCacheDriver * */ public function saveToCache($item_to_save) { $this->getCacheDriver()->save('foo_key', $item_to_save); -
peterjmit created this gist
Mar 6, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ <?php class Foo { private $_em; public function __construct($entity_manager) { $this->_em = $entityManager; } /** * I couldn't find any where in the Doctrine or Symfony docs that explained * how to get the Cache Driver defined in my config_prod.yml file for use * in saving custom arrays/keys. * * (Rather than directly instantiating a cache driver i.e. $cacheDriver = new \Doctrine\Common\Cache\ApcCache()) * * @return Implementation of Doctrine\Common\Cache\Cache (APC/Xcache etc.) */ public function getCacheDriver() { return $this->_em->getConfiguration()->getResultCacheImpl(); } public function saveToCache($item_to_save) { $this->getCacheDriver()->save('foo_key', $item_to_save); } }