Skip to content

ma-pony/asyncio-ttl-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

一个异步函数的带有 ttl 缓存功能的装饰器

Install

pip install asyncio-ttl-cache

Example

import asyncio
from asyncio_ttl_cache import ttl_cache


@ttl_cache(ttl=3)
async def sum(a: int, b: int) -> int:
    await asyncio.sleep(1)
    return a + b

if __name__ == '__main__':
    asyncio.run(sum(1, 2))

Releases

No releases published

Packages

No packages published

Languages