This module provides caching with support for different backends. The default implementation is ResponseCache.

Methods and Constants

The cache is disabled by default. Use it like so:

import logging
from sunlight import response_cache

Note: the implementation below doesn’t bother with cache expiration. Typical use case is caching API calls during an expensive build process.

class sunlight.cache.MemoryBackend[source]

In-memory cache for API responses.

class sunlight.cache.MongoBackend[source]

Mongo cache of API respones.

class sunlight.cache.ResponseCache[source]

Simple cache implementation with pickled strings as cache keys.

get_key(method_self, *args, **kwargs)[source]

Create a cache key by: pickle.dumps((module, name, args, kwargs))