Skip to main content

Top-level package for slycache.

Project description

https://img.shields.io/pypi/v/slycache.svg https://github.com/snopoke/slycache/actions/workflows/ci.yml/badge.svg Documentation Status

A caching API for python loosely modeled after the Java Caching API (JSR107).

Features

  • Simple decorator based API

  • Easily adapt any cache backend to work with slycache

Basic Usage

Start by registering a cache backend:

slycache.register_backend("default", my_cache_backend)

Define a key namespace:

# define a key namespace
user_cache = slycache.with_defaults(namespace="user")

Use the cache on methods and functions:

@user_cache.cache_result("{username}")
def get_user_by_username(username):
    ...

@user_cache.cache_result("{user_id}")
def get_user_by_id(user_id):
    ...

@user_cache.cache_put([
    "{user.username}", "{user.user_id}"
])
def save_user(user):
    ...

@user_cache.cache_remove([
    "{user.username}", "{user.user_id}"
])
def delete_user(user):
    ...

For more advanced usage see the documentation: https://slycache.readthedocs.io

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

slycache-0.1.0.tar.gz (13.2 kB view hashes)

Uploaded Source

Built Distribution

slycache-0.1.0-py3-none-any.whl (11.7 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