.. aiocache documentation master file, created by sphinx-quickstart on Sat Oct 1 16:53:45 2016. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. Welcome to aiocache's documentation! ==================================== Installing ---------- - ``pip install aiocache`` - ``pip install aiocache[redis]`` - ``pip install aiocache[memcached]`` - ``pip install aiocache[redis,memcached]`` Usage ----- Using a cache is as simple as .. code-block:: python >>> import asyncio >>> from aiocache import Cache >>> cache = Cache() >>> with asyncio.Runner() as runner: >>> runner.run(cache.set("key", "value")) True >>> runner.run(cache.get("key")) 'value' Here we are using the :ref:`simplememorycache` but you can use any other listed in :ref:`caches`. All caches contain the same minimum interface which consists on the following functions: - ``add``: Only adds key/value if key does not exist. Otherwise raises ValueError. - ``get``: Retrieve value identified by key. - ``set``: Sets key/value. - ``multi_get``: Retrieves multiple key/values. - ``multi_set``: Sets multiple key/values. - ``exists``: Returns True if key exists False otherwise. - ``increment``: Increment the value stored in the given key. - ``delete``: Deletes key and returns number of deleted items. - ``clear``: Clears the items stored. - ``raw``: Executes the specified command using the underlying client. You can also setup cache aliases like in Django settings: .. literalinclude:: ../examples/cached_alias_config.py :language: python :linenos: :emphasize-lines: 6-26 In `examples folder `_ you can check different use cases: - `Sanic, Aiohttp and Tornado `_ - `Python object in Redis `_ - `Custom serializer for compressing data `_ - `TimingPlugin and HitMissRatioPlugin demos `_ - `Using marshmallow as a serializer `_ - `Using cached decorator `_. - `Using multi_cached decorator `_. Contents -------- .. toctree:: caches serializers plugins configuration decorators locking testing Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search`