views:

516

answers:

2

Trying to configure Zend_Cache_Backend_Memcached via a config.ini or config.xml file. I'm not sure how to represent the array of servers in an ini file as described in the documentation

A: 

You can probably put this information in the Zend_Registry. If that isn't loaded early enough in the processes, then you can put a big array declaration in a php file, and require_once it where needed.

Dana the Sane
I want to keep all my configs in one place. Specifically in a ini or xml file.
Akeem
You can keep your configuration in a single place with either approach. With larger projects though, it's advisable to keep the scope of your config files narrow because some code may not need all settings.
Dana the Sane
There is no need to put this information in the registry, you should use the app config for such things, (you can use a php array instead of ini format and get advantages like APC caching see http://dasprids.de) bit putting this in the app config makes sense. I would suggest creating a custom resource plugin, which can then register your cache object in the registry, or use your own singleton implementation to fetch multiple front/backends throught your app.
Bittarman
This isn't much different than my second suggestion. If you feel the question is lacking in detail, feel free to expand on it in an answer of your own.
Dana the Sane
+1  A: 

The standard way to represent an array while using Zend_Config_Ini is to just make some nonsense keys:

 cache.backend.memcache.servers.foo.host = host1.example.com
 cache.backend.memcache.servers.foo.port = 11211
 ...
 cache.backend.memcache.servers.bar.host = host2.example.com
 cache.backend.memcache.servers.bar.port = 12345;
jason
useful names might help more than nonsense keys, like some hint to which server it is, but this is pretty much on the money
Bittarman
Yes, I completely agree that for a self-explanatory config file, useful names are must; however, the key names have no tangible impact on `Zend_Cache`
jason