<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="./style/manual.en.xsl"?>
<!-- $LastChangedRevision$ -->

<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<manualpage metafile="socache.xml.meta">

  <title>Shared Object Cache in Apache HTTP Server</title>

  <summary>
    <p>The Shared Object Cache provides a means to share simple data
    across all a server's workers, regardless of <a href="mpm.html">thread
    and process models</a>.  It is used where the advantages of sharing
    data across processes outweigh the performance overhead of
    inter-process communication.</p>
  </summary>

  <section id="providers">
    <title>Shared Object Cache Providers</title>
    <p>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.</p>
    <p>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
    <directive module="mod_cache_socache">CacheSocache</directive>,
    <directive module="mod_authn_socache">AuthnCacheSOCache</directive>,
    <directive module="mod_ssl">SSLSessionCache</directive>, and
    <directive module="mod_ssl">SSLStaplingCache</directive>.</p>
    <p>Currently available providers are:</p>
    <dl>
    <dt>"dbm" (<module>mod_socache_dbm</module>)</dt>
    <dd>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.</dd>
    <dt>"dc" (<module>mod_socache_dc</module>)</dt>
    <dd>This makes use of the <a href="http://distcache.sourceforge.net/">distcache</a>
    distributed session caching libraries.</dd>
    <dt>"memcache" (<module>mod_socache_memcache</module>)</dt>
    <dd>This makes use of the <a href="http://memcached.org/">memcached</a>
    high-performance, distributed memory object caching system.</dd>
    <dt>"shmcb" (<module>mod_socache_shmcb</module>)</dt>
    <dd>This makes use of a high-performance cyclic buffer inside a
     shared memory segment.</dd>
    </dl>

    <p>The API provides the following functions:</p>

    <dl>
      <dt>const char *create(ap_socache_instance_t **instance, const char *arg,
                          apr_pool_t *tmp, apr_pool_t *p);</dt>
      <dd>Create a session cache based on the given configuration string.
      The instance pointer returned in the instance parameter will be
      passed as the first argument to subsequent invocations.</dd>

      <dt>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)</dt>
      <dd>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.</dd>

      <dt>void destroy(ap_socache_instance_t *instance, server_rec *s)</dt>
      <dd>Destroy a given cache instance object.</dd>

      <dt>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)</dt>
      <dd>Store an object in a cache instance.</dd>

      <dt>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)</dt>
      <dd>Retrieve a cached object.</dd>

      <dt>apr_status_t remove(ap_socache_instance_t *instance, server_rec *s,
                           const unsigned char *id, unsigned int idlen,
                           apr_pool_t *pool)</dt>
      <dd>Remove an object from the cache.</dd>

      <dt>void status(ap_socache_instance_t *instance, request_rec *r, int flags)</dt>
      <dd>Dump the status of a cache instance for mod_status.</dd>

      <dt>apr_status_t iterate(ap_socache_instance_t *instance, server_rec *s,
                            void *userctx, ap_socache_iterator_t *iterator,
                            apr_pool_t *pool)</dt>
      <dd>Dump all cached objects through an iterator callback.</dd>
    </dl>

  </section>

</manualpage>
