`'cacheDir' => __DIR__ . '/../../../data/cache',` should not be needed, as in a default setup, you have your CWD set to the application root. `data/cache` should be enough :) Marco Pivetta
http://twitter.com/Ocramius http://marco-pivetta.com On 13 May 2012 02:02, cmple [via Zend Framework Community] < [email protected]> wrote: > boosis wrote > Hi cmple, > > That didn't work initially, threw this message > PHP Fatal error: Uncaught exception 'ReflectionException' with message > 'Class Zend\\Cache\\Storage\\Adapter does not exist' > changed the adapter to abstractadapter and it worked. But could you tell > me > how to configure the Filesystem cache adapter, ie, I want to change the > cacheDir. > > > Thanks > Bill > > > On 12 May 2012 18:45, cmple <[hidden > email]<http://user/SendEmail.jtp?type=node&node=4629759&i=0>> > wrote: > > > Hey Bill, > > > > This should work: > > > > > http://zend-framework-community.634137.n4.nabble.com/ZF2-Factory-method-and-Zend-Di-td4257197.html#a4557174 > > > > > > boosis wrote > > > > > > Hi, > > > > > > I am trying to inject Zend Filesystem cache to my service class but > > > couldn't manage to do it. My DI configuration looks like this > > > > > > return array( > > > 'di' => array( > > > 'instance' => array( > > > 'alias' => array( > > > 'file_cache' => > 'Zend\Cache\Storage\Adapter\Filesystem', > > > 'file_cache_options' => > > > 'Zend\Cache\Storage\Adapter\FilesystemOptions', > > > ), > > > 'file_cache_options' => array( > > > 'parameters' => array( > > > 'cacheDir' => '/opt', > > > 'dirUmask' => '0777' > > > ), > > > ), > > > 'file_cache' => array( > > > 'parameters' => array( > > > 'options' => 'file_cache_options' > > > ), > > > ), > > > 'Application\Domain\Service\Deal' => array( > > > 'parameters' => array( > > > 'mapper' => 'Application\Domain\Mapper\Deal', > > > 'cache' => 'file_cache' > > > ), > > > ), > > > > > > But when I dump the cache object in the Mapper Deal object I get the > > cache > > > object with default settings. i.e. I try to set the cacheDir to /opt > but > > > dump still shows /tmp. So I guess FilesystemOptions is not injected > > > correctly. > > > > > > Could someone shed some light on this? > > > > > > Thanks > > > Bill > > > > > > > > > -- > > View this message in context: > > > http://zend-framework-community.634137.n4.nabble.com/Setting-up-Zend-Filesystem-Cache-with-DI-tp4629194p4629212.html > > Sent from the Zend Framework mailing list archive at Nabble.com. > > > > -- > > List: [hidden email]<http://user/SendEmail.jtp?type=node&node=4629759&i=1> > > Info: http://framework.zend.com/archives > > Unsubscribe: [hidden > > email]<http://user/SendEmail.jtp?type=node&node=4629759&i=2> > > > > > > > > try this: > > //module.config.php > <?php > return array( > 'di' => array( > 'definition' => array( > 'class' => array( > 'Zend\Cache\Storage\Adapter\Filesystem' => array( > 'instantiator' => array( > 'Zend\Cache\StorageFactory', > 'factory' > ), > ), > 'Zend\Cache\StorageFactory' => array( > 'methods' => array( > 'factory' => array('cfg' => array( > 'required' => true, > 'type' => false, > )) > ), > ), > ), > ), > 'instance' => array( > 'alias' => array( > 'cache' => 'Zend\Cache\Storage\Adapter\Filesystem', > ), > 'cache' => array( > 'parameters' => array('cfg' => array( > 'adapter' => array( > 'name' => 'filesystem', > 'options' => array( > 'dirLevel' => 2, > *'cacheDir' => __DIR__ . > '/../../../data/cache',* > ), > ), > 'plugins' => array( > 'serializer' > ), > ), > ), > ), > > ), > ), > ); > > > //Module/Module.php > <?php > > namespace Application; > > use Zend\Module\Manager, > Zend\EventManager\StaticEventManager, > Zend\Module\Consumer\AutoloaderProvider, > Zend\Navigation\Page\Mvc as PageMvc; > > class Module implements AutoloaderProvider { > > //.... > > public function initializeView($e) > { > $app = $e->getParam('application'); > $basePath = $app->getRequest()->getBasePath(); > $locator = $app->getLocator(); > $renderer = $locator->get('Zend\View\Renderer\PhpRenderer'); > $renderer->plugin('url')->setRouter($app->getRouter()); > $renderer->doctype()->setDoctype('HTML5'); > $renderer->plugin('basePath')->setBasePath($basePath); > > $this->setCache($locator->get('cache')); > > } > > public static function getCache() { > return static::$cache; > } > > public function setCache($cache) { > static::$cache = $cache; > } > > //.... > } > > > > > <?php > namespace Application\Model; > > use Application\Module; > > class MyModel { > > public function cacheTest(){ > > $cache = Module::getCache(); > //... do some cache magic > > } > > } > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://zend-framework-community.634137.n4.nabble.com/Setting-up-Zend-Filesystem-Cache-with-DI-tp4629194p4629759.html > To unsubscribe from Zend Framework Community, click > here<http://zend-framework-community.634137.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=634137&code=b2NyYW1pdXNAZ21haWwuY29tfDYzNDEzN3wxNzE0OTI1MTk4> > . > NAML<http://zend-framework-community.634137.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/Setting-up-Zend-Filesystem-Cache-with-DI-tp4629194p4629891.html Sent from the Zend Framework mailing list archive at Nabble.com.
