Skip to main content

Decorator to cache to Deta base

Project description

DetaCache

Async Function Decorator to cache to Deta base.

Installing

pip3 install DetaCache

Async

import asyncio
import aiohttp
from DetaCache import detaCache
from deta import Deta

db = Deta('project_key').Base("base_name")


@detaCache(dbCache=db,urlArg='url')
async def getjSON(url:str):
    async with aiohttp.ClientSession() as session:
        async with session.get(url) as response:
            return await response.json()

async def main():
    data = await getjSON(url='https://httpbin.org/json')
    print(data)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

License

MIT License

Copyright (c) 2021 Vidya Sagar

Project details


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.1.tar.gz (2.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page