Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

easycaching-0.103-py3-none-any.whl (7.1 kB view hashes)

Uploaded Python 3

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