hubgrep.lib.cached_session.cached_session module

A CachedSession wraps requests.Session, to conditionally retrieve cached responses when available, or send a new request.

Note: All responses coming from a CachedSession are wrapped by CachedResponse, regardless if they were cached or not.

class hubgrep.lib.cached_session.cached_session.CachedSession(session: requests.sessions.Session, cache: Union[hubgrep.lib.cached_session.caches.no_cache.NoCache, hubgrep.lib.cached_session.caches.redis_cache.RedisCache])

Bases: object

Wrapper class for request session, caches results and exceptions.

get(url, *args, **kwargs)hubgrep.lib.cached_session.cached_response.CachedResponse

Send a GET request.

property headers
make_key(method, url, *args, **kwargs)

Make a unique hash from a request used as a key in the cache.

request(method, url, *args, **kwargs)hubgrep.lib.cached_session.cached_response.CachedResponse

Retrieve a cached request if available, or make an actual request.