Skip to main content

Modern cache for modern people

Project description

Weller

Installation:

pip install weller

What is it?

weller it's a modern library for caching. It add a TTL cache per item, auto values refresh and also so easy interface for ruling this

What it includes:

  • Weller - a automatic dispatcher for your perfect cache
  • StrictCached and LazyCached - a simply TTL cache per item
  • StrictAutoCached and LazyAutoCached - the same as the upper one, but with automatic values refresh

Strict and Lazy difference

This library has the concept of strict and lazy caches.

  • First, the Lazy, deletes or refreshes only the data that you receive
  • Second, the Strict, deletes or refreshes all data from a storage per any request

Usage examples:

import asyncio
from typing import Any, Annotated

from weller import Weller, Depends
from weller.dispather.storage import WellerMemoryStorage


storage = WellerMemoryStorage()


# If first_long = True, then first get of data will download all the data. Default False
weller = Weller(storage=storage, first_long=False)

async def get_db() -> dict[str, Any]:
    return {"some_key": "some_data"}


@weller.add("some_long", duration=5)
async def get_long_data(db: Annotated[dict, Depends(get_db)]):
    await asyncio.sleep(2)

    return db.get("some_key")


async def main():
    await weller.get("some_long")  # it will take 2 seconds
    await weller.get("some_long")  # but it will be done instantly

    
asyncio.run(main())

You can see other examples in weller -> examples

Documentation:

In development and will be available soon

Roadmap:

  • Add redis storage
  • Work and with stability and security

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

weller-0.0.0a1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

weller-0.0.0a1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file weller-0.0.0a1.tar.gz.

File metadata

  • Download URL: weller-0.0.0a1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Windows/10

File hashes

Hashes for weller-0.0.0a1.tar.gz
Algorithm Hash digest
SHA256 8742b5bbe06d09af3d2be5c2df7031136ec904e04b02e4df51545a78e79ab075
MD5 408283de09db01c5d3e0517c1ca8c9be
BLAKE2b-256 06403a1cbd16ee0e7baef53bc367981800a92b658dd9b4bf105950969d341f37

See more details on using hashes here.

File details

Details for the file weller-0.0.0a1-py3-none-any.whl.

File metadata

  • Download URL: weller-0.0.0a1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Windows/10

File hashes

Hashes for weller-0.0.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 ec7a32e6f44ac07e67c14233d6a15af49bc4411a58cfc322b872003a68378080
MD5 e68d1f68d89894f14ad5f218eeae869a
BLAKE2b-256 2edbd437cb18faadd67dc304e9afca6a7adc9c74802815356574363554de5cb9

See more details on using hashes here.

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