Q:

Memcached - Single parent config, multiple child configs

I am setting up a memcached server in production, and would like the ability to switch between various memory sizes simply by changing out a symlink from one config to another, however I do not want to copy and paste every config into every other config, is it possible to have a master config with multiple child configs?
Example:
# master config
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="128"
OPTIONS=""

# Name: memcached_256
# child config for cache server of 256
# include options from master config
CACHESIZE="256"

# Name: memcached_512
# child config for cache server of 512
# include options from master config
CACHESIZE="512"

Example dir listing:
ls /etc/sysconfig

memcached -> /path/to/my/version/controlled/configs/memcached_256

And if I ever need to upgrade, I can simply change the above symlink to:
memcached -> /path/to/my/version/controlled/configs/memcached_512

Then after changing out the symlink, simply restart the service. Or if there is a better way to accomplish this functionality, that would be appreciated as well.

A:

It looks like those files are sourced by the initscript which starts memcached, and not read by memcached itself. You could therefore probably source the master configuration from the child configurations, for example:
/etc/sysconf/memcached_master:
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="128"
OPTIONS=""

/etc/sysconf/memcached_256:
. /etc/sysconfig/memcached_master
CACHESIZE="256"

/etc/sysconf/memcached_512:
. /etc/sysconfig/memcached_master
CACHESIZE="512"

And then symlink /etc/sysconfig/memcached to the child configuration you want to use.

