Apache > HTTP Server > Documentation > Version 2.5

Shared Object Cache in Apache HTTP Server

Available Languages:  en  |  fr 

The Shared Object Cache provides a means to share simple data across all a server's workers, regardless of thread and process models. It is used where the advantages of sharing data across processes outweigh the performance overhead of inter-process communication.


Shared Object Cache Providers

The shared object cache as such is an abstraction. Four different modules implement it. To use the cache, one or more of these modules must be present, and configured.

The only configuration required is to select which cache provider to use. This is the responsibility of modules using the cache, and they enable selection using directives such as CacheSocache, AuthnCacheSOCache, SSLSessionCache, and SSLStaplingCache.

Currently available providers are:

"dbm" (mod_socache_dbm)
This makes use of a DBM hash file. The choice of underlying DBM used may be configurable if the installed APR version supports multiple DBM implementations.
"dc" (mod_socache_dc)
This makes use of the distcache distributed session caching libraries.
"memcache" (mod_socache_memcache)
This makes use of the memcached high-performance, distributed memory object caching system.
"shmcb" (mod_socache_shmcb)
This makes use of a high-performance cyclic buffer inside a shared memory segment.

The API provides the following functions:

const char *create(ap_socache_instance_t **instance, const char *arg, apr_pool_t *tmp, apr_pool_t *p);
Create a session cache based on the given configuration string. The instance pointer returned in the instance paramater will be passed as the first argument to subsequent invocations.
apr_status_t init(ap_socache_instance_t *instance, const char *cname, const struct ap_socache_hints *hints, server_rec *s, apr_pool_t *pool)
Initialize the cache. The cname must be of maximum length 16 characters, and uniquely identifies the consumer of the cache within the server; using the module name is recommended, e.g. "mod_ssl-sess". This string may be used within a filesystem path so use of only alphanumeric [a-z0-9_-] characters is recommended. If hints is non-NULL, it gives a set of hints for the provider. Return APR error code.
void destroy(ap_socache_instance_t *instance, server_rec *s)
Destroy a given cache instance object.
apr_status_t store(ap_socache_instance_t *instance, server_rec *s, const unsigned char *id, unsigned int idlen, apr_time_t expiry, unsigned char *data, unsigned int datalen, apr_pool_t *pool)
Store an object in a cache instance.
apr_status_t retrieve(ap_socache_instance_t *instance, server_rec *s, const unsigned char *id, unsigned int idlen, unsigned char *data, unsigned int *datalen, apr_pool_t *pool)
Retrieve a cached object.
apr_status_t remove(ap_socache_instance_t *instance, server_rec *s, const unsigned char *id, unsigned int idlen, apr_pool_t *pool)
Remove an object from the cache.
void status(ap_socache_instance_t *instance, request_rec *r, int flags)
Dump the status of a cache instance for mod_status.
apr_status_t iterate(ap_socache_instance_t *instance, server_rec *s, void *userctx, ap_socache_iterator_t *iterator, apr_pool_t *pool)
Dump all cached objects through an iterator callback.

Available Languages:  en  |  fr 



This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our mailing lists.