Shared, persistent, and smart caching via a single shared interface for storing and retreiving data from memory among many processes(forks) of an application
Project description
Shared, persistent, and smart caching
What is it?
easycaching provides a single shared interface for storing and retreiving data from memory among many processes(forks) of an application.
Features
- fast and shared access to data
- persistent cache backed by a database
- auto-forking
- python syntax
Get Started
pip install easycaching
Usage
import asyncio
from easycaching import EasyCache
async def main():
cache = await EasyCache.create(
'test'
)
# set
await cache.set('foo', 'bar')
# get
cached_value = await cache.get('foo')
# set with json structured data
await cache.set('foo_json', {'bar': 'bar_json'})
asyncio.run(main())
FastAPI Usage
# basic.py
from fastapi import FastAPI
from easycaching import EasyCache
app = FastAPI()
@app.on_event('startup')
async def start_cache():
app.cache = await EasyCache.create(
'test'
)
@app.get('/cache')
async def view_cache(key: str):
return {
key: await app.cache[key]
}
@app.post('/cache')
async def set_cache(key: str, value: str):
return await app.cache.set(key, {'json': value})
uvicorn --host 0.0.0.0 --port 8230 basic:app --workers=5
Under the Hood
easycaching utilizes the smart caching of aiopyql to provide cache acesss, cache storage, and perhaps most importantly updates and invalidation.
Data access sharing is made possible via proxy methods using easyrpc. A cache background task is created & managed by gunicorn which main application workers access via proxies.
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 Distributions
Built Distribution
Hashes for easycaching-0.101-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 181d98052e4520b4c84bd8c3c549d748942108436b3a6032d11312bc0262ebb5 |
|
MD5 | 404c1a207d79f2d2e086d45b0825e2b2 |
|
BLAKE2b-256 | cfcea87db9b54783a18df5da2851981b6db1bf0b60f72ee4ff6772e43e21e2e1 |