Skip to content

Lightweight, framework agnostic caching library with sweet API

Notifications You must be signed in to change notification settings

daGrevis/sweetcache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sweetcache

Lightweight, framework agnostic caching library with sweet API

Project Status: Wip - Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.

NB! API is expected to change!

Usage

from datetime import datetime, timedelta

import sweetcache
import sweetcache_redis


cache = sweetcache.Cache(sweetcache_redis.RedisBackend)


cache.set("foo", 42)
assert cache.get("foo") == 42


user = {
    "id": 1,
    "username": "daGrevis",
}
cache.set(["users.v1", user["id"]], user)


cache.set("foo", 42, expires=timedelta(minutes=5))
cache.set("foo", 42, expires=datetime(2015, 9, 28))
cache.set("foo", 42, expires=60 * 5)


try:
    foo = cache.get("foo")
except sweetcache.NotFoundError:
    foo = None

foo = cache.get("foo", None)


@cache.it("charts.v2", expires=timedelta(hours=2))
def get_charts():
    charts = calculate_charts()
    return charts

Running Tests

nosetests -s sweetcache

With Coverage

nosetests -s sweetcache --with-coverage --cover-html --cover-package sweetcache

About

Lightweight, framework agnostic caching library with sweet API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages