Async and Sync Function Decorator to cache function call's to Deta base
Project description
DetaCache
Async and Sync Function Decorator to cache function call's to Deta base.
Installing
pip3 install detacache
Async and Sync Decorator to cache function
import asyncio
import aiohttp
import requests
from DetaCache import detaCache
app = detaCache('projectKey')
@app.cache(expire=30)
async def asyncgetjSON(url:str):
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
return await response.json()
@app.cache(expire=30)
def syncgetjSON(url:str):
return requests.get(url).json()
async def main():
asyncdata = await asyncgetjSON('https://httpbin.org/json')
print(asyncdata)
syncdata = syncgetjSON('https://httpbin.org/json')
print(syncdata)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
License
MIT License
Copyright (c) 2021 Vidya Sagar
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
detacache-0.0.8.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for detacache-0.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 290e4db8ab7044ee5a6d8a4a20dc0b37da95fb9a751508c4b3f1f8db02b9496f |
|
MD5 | ae352931506eb6470673853cda21ee9e |
|
BLAKE2b-256 | b8bac951ca8e41f868e943e142e59050062f9bde1cb6b1fbee94a6e90c034108 |