-- Dan Wilson <d...@codeality.com> wrote (on Thursday, 18 December 2008, 01:21 PM -0700): > I've added Zend_Cache to my project, but have multiple environments. > I'm using memcache as my backend, but only in one environment. In the > other environment, I don't want caching enabled at all. When I try to > disable caching however, it still tries to instantiate the Memcache > object. I don't have memcache on that machine and so it barfs on me. > > Why doesn't the caching enabled flag prevent this? It looks to me > like we might need an additional caching enabled flag for the backend > as well as the frontend. > > Any thoughts?
I'm not sure why it works this way, actually; hopefully Fabien will be able to fill us in on that. As for using multiple environments... I made some changes to Zend_Cache for either 1.7.0 or 1.7.1 that fixes an issue that existed when using configuration -- basically, prior to the fix, you couldn't have specify different frontend/backend combinations in your config file because the differing options between them would cause exceptions to be raised. The fix now ignores options that don't exist for the given adapter. This allows you to do something like the following: [production] cache.frontendName = "Core" cache.frontendOptions.caching = false cache.frontendOptions.lifetime = 900 cache.frontendOptions.automatic_serialization = true cache.frontendOptions.automatic_cleaning_factor = 20 cache.backendName = "File" cache.backendOptions.cache_dir = APPLICATION_PATH "/../data/cache/files" cache.backendOptions.read_control = false cache.backendOptions.file_name_prefix = "cache" [development : production] cache.frontendOptions.caching = false cache.backendName = "Sqlite" cache.backendOptions.cache_db_complete_path = APPLICATION_PATH "/../data/cache/cache-dev.db" cache.backendOptions.automatic_vacuum_factor = 20 [testing : production] cache.frontendOptions.caching = false cache.backendName = "Sqlite" cache.backendOptions.cache_db_complete_path = APPLICATION_PATH "/../data/cache/cache-test.db" cache.backendOptions.automatic_vacuum_factor = 20 Note that I have a different backend in production than in development or testing. Using this approach, you can specify memcached for your production environment, and then use File or Sqlite for the other environments -- and have no ill effects due to lack of available services. -- Matthew Weier O'Phinney Software Architect | matt...@zend.com Zend Framework | http://framework.zend.com/