跳转到主要内容

未提供项目描述

项目描述

pyappcache

Pyappcache 是一个库,使Python中应用级缓存的使用更加容易。

  • 允许将任意Python对象放入缓存

  • 使用PEP484类型提示来帮助您检查缓存返回值的类型

  • 支持Memcache、Redis和SQLite

  • 支持作为“读通”和“写通”缓存工作

  • 原生支持键 "namespacing" <https://github.com/memcached/memcached/wiki/ProgrammingTricks#namespacing>__

  • 提供了一些实用的额外功能

    • cachecontrol <https://pypi.ac.cn/project/CacheControl/>__ 库提供的插件,因此您也可以将其用作HTTP缓存与 requests <https://pypi.ac.cn/project/requests/>__

一个简单的示例

.. code:: python

from datetime import date

from pyappcache.redis import RedisCache
from pyappcache.keys import Key, SimpleStringKey

cache = RedisCache()

# Annotate the type here to let mypy know this key is used for dates
key: Key[date] = SimpleStringKey("mifid start date")
cache.set(key, date(2018, 1, 3), ttl_seconds=3600)

... # later...

# This variable's type will be inferred as datetime.date
special_date = cache.get(key)

与替代方案的比较

直接使用redis/memcache/sqlite客户端


- Explicit key objects allow for type inference and encapsulation of keying
- Keys are prefix to help prevent collisions
- Optional, pluggable, compression
- Hopefully the overhead is small (not yet tested!)
- Portable between redis/memcache/sqlite, etc

dogpile.cache
~~~~~~~~~~~~~

- Explicit key objects allow for type inference and encapsulation of keying
- dogpile.cache provides locking, pyappcache does not
- Reduced temptation to use the problematic decorator pattern
  - This often causes import order problems as you need to have your cache at import time
- Pyappache doesn't provide DBM/file backends, SQLite instead

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源代码分发

pyappcache-0.10.0.tar.gz (29.8 kB 查看哈希值)

上传时间 源代码

构建分发版

pyappcache-0.10.0-py3-none-any.whl (27.2 kB 查看哈希值)

上传时间 Python 3

由以下支持