Skip to content

Python cache library loosly modeled after the Java JSR107 spec

License

Notifications You must be signed in to change notification settings

snopoke/slycache

Repository files navigation

slycache

PyPi version

Python versions

Build status

Documentation Status

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

Note

This library is in Alpha stage and not ready for production use.

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

About

Python cache library loosly modeled after the Java JSR107 spec

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages