A simple cache library.
Project description
ff-cache
一个简洁易用的 cache 封装库。
主要功能
- 通过注解
cache来对函数执行结果进行缓存处理 - 支持对缓存进行标签分组管理
- 支持 memory / redis 缓存
- 支持自定义缓存逻辑(缓存key、根据结果动态计算缓存时间)
安装
pip install ff-cache
快速开始
from ff_cache import ContextManager, MemoryCache, cache
from ff_cache.redis import RedisCache
redis_url = "redis://localhost:6379/0"
ContextManager.init(cache=RedisCache(url=redis_url))
@cache()
def hello_world():
"""
"""
print("function executed.")
return "hello world"
if __name__ == '__main__':
print(hello_world()) # 第一次执行,控制台打印出:function executed.
print("---------------------------------")
print(hello_world()) # 第二次执行,控制台没有打印:function executed. 说明缓存成功
更多示例
请参考 tests 目录下的用例。
贡献指南
欢迎提交 Issue 或 PR,完善功能或修复问题。请确保代码风格与项目保持一致,并补充必要的测试。
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ff_cache-0.2.0.tar.gz
(10.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ff_cache-0.2.0.tar.gz.
File metadata
- Download URL: ff_cache-0.2.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a8234048a524e5c8e53c643795e2f27b4fdc5f7c0d8362ae1b7d8a45cec65bf
|
|
| MD5 |
b6c6fd8ed0519fea2870f471cedc8b92
|
|
| BLAKE2b-256 |
ceddd972989a64a922425fbcbab156cb0f7ec56865ffac552919c457940e48a6
|
File details
Details for the file ff_cache-0.2.0-py2.py3-none-any.whl.
File metadata
- Download URL: ff_cache-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7c78d03944435e2f3fafde47f5bb74c5e8b2bec48c8bc8ce6e5aef7d0107fc9
|
|
| MD5 |
43e026be5b162d8f06edd83c13a0dc1f
|
|
| BLAKE2b-256 |
f9dd7c13f0f42a0927a81bc6e722b61e42d2d16e7e39ef6326e453263fec55f0
|