Added new `cache` module to privex.helpers, overhauled docs
TL;DR; Created new module privex.helpers.cache for easy framework-agnostic caching, plus cleaned up many page titles in the docs
Caching:
- The main
privex.helpers.cachemodule exposes acachedattribute (from privex.helpers import cached) which
acts as a singleton adapter wrapper, so the global cache adapter can easily be switched out without any risk
of other parts of your code using the "old" adapter. - Created
CacheAdapterwhich is an abstract base class designed to set the standard for the cache API - Created
MemoryCachewhich is a simple caching layer with expiration support that simply stores cache items in memory
using a staticdictattribute. - Created
RedisCachewhich as it sounds, is a cache layer that uses Redis for it's backend. It uses the global Redis fromprivex.helpers.pluginby default,
however you can pass aredis.Redisclass instance to it's constructor to use a custom instance instead.
Unit testing:
- Created unit tests for
MemoryCache - Created unit tests for
RedisCache- based on the unit tests forMemoryCacheto avoid code duplication
Other Updates:
- Added two new functions to
privex.helpers.pluginconfigure_redisfor updating the global redis settings and automatically replacing the Redis instancereset_redisto close the current Redis connection, then delete and re-instantiate the Redis connector class.
- Added two new exceptions
CacheNotFoundandNotConfigured - Possibly some other small changes
Documentation
- Added very detailed documentation for the new
privex.helpers.cachemodule - Added documentation for
CacheAdapter - Added documentation for
MemoryCache - Added documentation for
RedisCache - Fixed some missing documentation entries
- Added slightly customized autosummary templates under
docs/source/_templatesto stop Sphinx using
ridiculously long namespaced methods/attributes for the page titles / navbar. - Regenerated lots of stub files in
docs/source/helpers/such ascommon/,exceptions/,net/, and others - fixes the long title issue permanently (see previous bullet point)