diff --git a/docs/index.rst b/docs/index.rst index 14fb0a6d..44e8c8b0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -544,4 +544,82 @@ Relevant configuration values SpreadSASLMemcachedCache ```````````````````````` -Set ``CACHE_TYPE`` to ``spreadsaslmemcached +Set ``CACHE_TYPE`` to ``spreadsaslmemcached`` to use this type. + +Same as SASLMemcachedCache however, it has the ablity to spread value across +multiple keys if it is bigger than the memcached treshold which by +default is 1M. Uses pickle. + +.. versionadded:: 0.11 + +.. versionchanged:: 1.1.0 + Renamed ``spreadsaslmemcachedcache`` to ``spreadsaslmemcached`` for + the sake of consistency. + + +Custom Cache Backends +--------------------- + +You are able to easily add your own custom cache backends by exposing a function +that can instantiate and return a cache object. ``CACHE_TYPE`` will be the +import string to your custom function. It should expect to receive three +arguments. + +* ``app`` +* ``args`` +* ``kwargs`` + +Your custom cache object must also subclass the +:class:`flask_caching.backends.cache.BaseCache` class. Flask-Caching will make sure +that ``threshold`` is already included in the kwargs options dictionary since +it is common to all BaseCache classes. + +An example Redis cache implementation:: + + #: the_app/custom.py + class RedisCache(BaseCache): + def __init__(self, servers, default_timeout=500): + pass + + def redis(app, config, args, kwargs): + args.append(app.config['REDIS_SERVERS']) + return RedisCache(*args, **kwargs) + +With this example, your ``CACHE_TYPE`` might be ``the_app.custom.redis`` + +An example PylibMC cache implementation to change binary setting and provide +username/password if SASL is enabled on the library:: + + #: the_app/custom.py + def pylibmccache(app, config, args, kwargs): + return pylibmc.Client(servers=config['CACHE_MEMCACHED_SERVERS'], + username=config['CACHE_MEMCACHED_USERNAME'], + password=config['CACHE_MEMCACHED_PASSWORD'], + binary=True) + +With this example, your ``CACHE_TYPE`` might be ``the_app.custom.pylibmccache`` + + +API +--- + +.. toctree:: + :maxdepth: 2 + + api + + +Additional Information +---------------------- + +.. toctree:: + :maxdepth: 2 + + changelog + license + +* :ref:`search` + + +.. _Flask: http://flask.pocoo.org/ +.. _werkzeug: http://werkzeug.pocoo.org/