Skip to content

Added new `cache` module to privex.helpers, overhauled docs

Choose a tag to compare

@Someguy123 Someguy123 released this 03 Oct 22:26
· 79 commits to master since this release

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.cache module exposes a cached attribute (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 CacheAdapter which is an abstract base class designed to set the standard for the cache API
  • Created MemoryCache which is a simple caching layer with expiration support that simply stores cache items in memory
    using a static dict attribute.
  • Created RedisCache which as it sounds, is a cache layer that uses Redis for it's backend. It uses the global Redis from privex.helpers.plugin by default,
    however you can pass a redis.Redis class 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 for MemoryCache to avoid code duplication

Other Updates:

  • Added two new functions to privex.helpers.plugin
    • configure_redis for updating the global redis settings and automatically replacing the Redis instance
    • reset_redis to close the current Redis connection, then delete and re-instantiate the Redis connector class.
  • Added two new exceptions CacheNotFound and NotConfigured
  • Possibly some other small changes

Documentation

  • Added very detailed documentation for the new privex.helpers.cache module
  • 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/_templates to stop Sphinx using
    ridiculously long namespaced methods/attributes for the page titles / navbar.
  • Regenerated lots of stub files in docs/source/helpers/ such as common/, exceptions/, net/, and others - fixes the long title issue permanently (see previous bullet point)