用于 Redis、memcached 和内存的 Asyncio 缓存管理器
aiocache ######## Asyncio 缓存支持多个后端 (内存、Redis、memcached 等)。 .. image:: https://codecov.io/gh/aio-libs/aiocache/branch/master/graph/badge.svg :target: https://codecov.io/gh/aio-libs/aiocache .. image:: https://badge.fury.io/py/aiocache.svg :target: https://pypi.python.org/pypi/aiocache .. image:: https://img.shields.io/pypi/pyversions/aiocache.svg :target: https://pypi.python.org/pypi/aiocache 此库的目标是简洁性而不是专业化。所有缓存都包含相同的最小接口,该接口包括以下函数:
add: 仅在键不存在时添加键/值。 - get: 获取通过键标识的值。 - set: 设置键/值。 - multi_get: 获取多个键/值。 - multi_set: 设置多个键/值。 - exists: 如果键存在,则返回 True,否则返回 False。 - increment: 增加指定键中存储的值。 - delete: 删除键并返回删除的项目数。 - clear: 清除存储的项目。 - raw: 使用底层客户端执行指定的命令。
pip install aiocache
pip install aiocache[Redis]
pip install aiocache[memcached]
pip install aiocache[Redis,memcached]
pip install aiocache[msgpack]
用法使用缓存的过程很简单,只需 .. code-block:: Python
导入 asyncio 从 aiocache 中导入 SimpleMemoryCache cache = SimpleMemoryCache() # 或 RedisCache、MemcachedCache 等 使用 asyncio.Runner() 如下: runner.run(cache.set('key', 'value')) 确实 runner.run(cache.get('key')) 'value' 或者作为装饰师 .. code-block:: Python import asyncio from collections import namedtuple
from aiocache import RedisCache, cached from aiocache.serializers import PickleSerializer
暂无开放 Issues,或尚未同步最近议题。