aiomemoize-0.0.3
توضیحات
Memoize asyncio Python function calls
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | aiomemoize-0.0.3 |
| نام | aiomemoize |
| نسخه کتابخانه | 0.0.3 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Michal Charemza |
| ایمیل نویسنده | michal@charemza.name |
| آدرس صفحه اصلی | https://github.com/michalc/aiomemoize |
| آدرس اینترنتی | https://pypi.org/project/aiomemoize/ |
| مجوز | - |
# aiomemoize [](https://circleci.com/gh/michalc/aiomemoize) [](https://codeclimate.com/github/michalc/aiomemoize/test_coverage)
Memoize asyncio Python calls. Invalidation is manual/explicit for each set of arguments, although exceptions raised are _not_ cached. This can be used for coroutines, and functions that return a promise.
## Installation
```base
pip install aiomemoize
```
## Usage
For a coroutine whose arguments are hashable, you can create a _memoized_ version by passing it to `memoize`. This returns a tuple of the memoized function, and a function to invalidate the cache on a per-item basis.
For example, the below
```python
import asyncio
from aiomemoize import memoize
async def main():
memoized, invalidate = memoize(coro)
results = await asyncio.gather(*[
memoized('a'),
memoized('a'),
memoized('b'),
])
print(results)
invalidate('a')
results = await asyncio.gather(*[
memoized('a'),
memoized('a'),
memoized('b'),
])
print(results)
await memoized('a')
async def coro(value):
print('Inside coro', value)
await asyncio.sleep(1)
return value
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
```
will output
```
Inside coro a
Inside coro b
['a', 'a', 'b']
Inside coro a
['a', 'a', 'b']
```
زبان مورد نیاز
| مقدار | نام |
|---|---|
| ~=3.5 | Python |
نحوه نصب
نصب پکیج whl aiomemoize-0.0.3:
pip install aiomemoize-0.0.3.whl
نصب پکیج tar.gz aiomemoize-0.0.3:
pip install aiomemoize-0.0.3.tar.gz