ZF-5034: Cache adapters should discard unrecognized options silently
Caching strategies often differ between development, testing, and production. However, it's convenient to utilize Zend_Config's inheritance features to define cache configuration. As an example:
[production] cache.backendName = "File" cache.frontendName = "Core" cache.frontendOptions.caching = false cache.frontendOptions.lifetime = 900 cache.frontendOptions.automatic_serialization = true cache.frontendOptions.automatic_cleaning_factor = 20 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
For example, in production, I want to use a file based cache strategy, as performance benchmarks have shown it to be faster than Sqlite; in development, I use Sqlite, as performance isn't a concern and I want an easy way to inspect the cache. However, when I call Zend_Cache::factory(), an exception is raised in development -- because the backend adapter does not recognize the "cache_dir" option (inherited from the production settings).
This is poor behavior on the part of Zend_Cache; unrecognized options should simply be ignored.