supervisor_cache is an RPC extension for the supervisor module that provides the ability to cache limited amounts of data in the supervisor instance as key/value pairs.
Release packages are available on the Python Package Index (PyPI). You can download them from there or you can use easy_install to automatically install or upgrade:
$ easy_install -U supervisor_cache
Alternatively, you can download a package from GitHub in .tar.gz or .zip format. After extracting the package, use the following command to install:
$ python setup.py install
After installing the package, you must modify your supervisord.conf file to register the RPC interface and supervisorctl plugin:
supervisor.rpcinterface_factory = supervisor_cache.rpcinterface:make_cache_rpcinterface
supervisor.ctl_factory = supervisor_cache.controllerplugin:make_cache_controllerplugin
After modifying the supervisord.conf file, both your supervisord instance and supervisorctl must be restarted for these changes to take effect.
The cache functions allow key/value pairs to be stored and fetched. The following Python interpreter session demonstrates the usage.
First, a ServerProxy object must be configured. If supervisord is listening on an inet socket, ServerProxy configuration is simple:
>>> import xmlrpclib
>>> s = xmlrpclib.ServerProxy('http://localhost:9001')
If supervisord is listening on a domain socket, ServerProxy can be configured with SupervisorTransport. The URL must still be supplied and be a valid HTTP URL to appease ServerProxy, but it is superfluous.
>>> import xmlrpclib
>>> from supervisor.xmlrpc import SupervisorTransport
>>> s = xmlrpclib.ServerProxy('http://127.0.0.1/whatever',
... SupervisorTransport('', '', 'unix:///path/to/supervisor.sock'))
Once ServerProxy has been configured appropriately, we can now exercise supervisor_cache:
>>> s.cache.store('foo', 'bar')
The key must be a string and cannot be zero-length. The value must also be a string but is permitted to be zero-length.
Please consult the inline source documentation for the specifics of each command available.