# utils-py
![Continuous Integration](https://github.com/outcome-co/utils-py/workflows/Continuous%20Integration/badge.svg) ![version-badge](https://img.shields.io/badge/version-5.0.4-brightgreen)
A set of python utilities.
## Usage
```sh
poetry add outcome-utils
```
### Cache
To add cache to a module
``` python
from outcome.utils import cache
cache_settings = {
'<your_prefix>.expiration': 300, # Default
'<your_prefix>.backend': 'memory', # Default
}
region = cache.get_cache_region()
cache.configure_cache_region(region, settings=cache_settings, prefix='<your_prefix>')
```
Then add to the functions to cache:
``` python
@region.cache_on_arguments()
def func_to_cache():
...
```
Or for async functions:
``` python
@region.cache_on_arguments()
@cache.cache_async
async def async_func_to_cache():
...
```
To have the cache persist on disk, specify the path
``` python
from pathlib import Path
cache_settings = {
...
'<your_prefix>.cache_path': f'{Path.home()}/.cache/example_path/cache.pkl'',
...
}
```
## Development
Remember to run `./pre-commit.sh` when you clone the repository.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共23个文件
py:19个
toml:1个
typed:1个
资源分类:Python库 所属语言:Python 资源全名:outcome-utils-5.0.4.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
outcome-utils-5.0.4.tar.gz (23个子文件)
outcome-utils-5.0.4
PKG-INFO 2KB
pyproject.toml 2KB
src
outcome
utils
bin
otc_utils.py 347B
feature_set.py 4KB
py.typed 8B
reraise.py 3KB
transformer_dict.py 1KB
pre_condition.py 3KB
transactions.py 6KB
meta.py 3KB
provider_state.py 1KB
__init__.py 117B
jinja2
regex_replace.py 636B
extend.py 634B
__init__.py 111B
semver.py 679B
env.py 3KB
config.py 7KB
loader.py 789B
cache.py 5KB
pyproject.py 593B
setup.py 2KB
README.md 1KB
共 23 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功