Skip to main content

This library provides a decorator for caching functions

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Cache Toolz

Maintenance Documentation Status Badge License Number of issues

CI codecov Repo Size

Supported Python versions PyPI version PyBuilder Downloads Per Day PyBuilder Downloads Per Week PyBuilder Downloads Per Month


Usage

from cachetoolz import cache


# Add cache so you don't always have to access the database, for example
@cache(namespace='todo')
async def get_todos(title=None, status=None):
    """Get all todos filtering by title or status."""


# Clear all caches in all namespaces so that no function has the result lagged to the database for example
@cache.clear(namespaces=['todo'])
async def add_todo(title, status=False):
    """Add todo."""

Remote backends

Redis

from cachetoolz import AsyncRedisBackend, Cache

cache = Cache(AsyncRedisBackend('redis://localhost:6379/0'))


@cache(namespace='todo')
async def get_todos(title=None, status=None):
    """Get all todos filtering by title or status."""


@cache.clear(namespaces=['todo'])
async def add_todo(title, status=False):
    """Add todo."""

Mongo

from cachetoolz import AsyncMongoBackend, Cache

cache = Cache(AsyncMongoBackend('mongodb://username:password@localhost:27017'))


@cache(namespace='todo')
async def get_todos(title=None, status=None):
    """Get all todos filtering by title or status."""


@cache.clear(namespaces=['todo'])
async def add_todo(title, status=False):
    """Add todo."""

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

cachetoolz-0.0.1.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cachetoolz-0.0.1-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file cachetoolz-0.0.1.tar.gz.

File metadata

  • Download URL: cachetoolz-0.0.1.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.19.0-46-generic

File hashes

Hashes for cachetoolz-0.0.1.tar.gz
Algorithm Hash digest
SHA256 034f7792778d8c980450624f6c28ee39e625c067159e49534dcbafac37477ee2
MD5 942642666c054cd61e5ee29a002b89de
BLAKE2b-256 4954f4de37c720d6986c248e1fc7f85cc0fb70ee441c956c2faff8492e141678

See more details on using hashes here.

File details

Details for the file cachetoolz-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: cachetoolz-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.19.0-46-generic

File hashes

Hashes for cachetoolz-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 63d276bbe45170fa15e452f6a2729031b93512b8912965ff0b3af73b0e6487c5
MD5 a1d17498b1d4ac95e0779616b2c511d0
BLAKE2b-256 f2a42be1ea925348ae134e1a9369769a4e90e7bc13dc951dbb5232d6d3fdb77c

See more details on using hashes here.

Supported by

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