3.1.0 - Added SqliteCache + AsyncSqliteCache, plus minor fixes in privex.helpers.plugin
privex.helpers.cache
-
Added
SqliteCachemodule, containing the synchronous cache adapterSqliteCachewhich uses an Sqlite3 database for persistent cache storage without the need for any extra system service (unlike the memcached / redis adapters) -
Added
asyncx.AsyncSqliteCachemodule, containing the AsyncIO cache adapterAsyncSqliteCache, which is simply an AsyncIO version ofSqliteCacheusing theaiosqlitelibrary.- NOTE: Due to the file-based nature of SQLite3, combined with the fact write operations generally result in the database being locked until the write is completed - use of the AsyncIO SQLite3 cache adapter only slightly improves performance, due to the blocking single-user nature of SQLite3.
-
Added
post_depsmodule, short for post-init dependencies. This module contains functions and classes which are known to have (or have a high risk of) recursive import conflicts - e.g. the new SQLite caching uses theprivex-dbpackage, and theprivex-dbpackage imports various things fromprivex.helperscausing a recursive import issue if we loadprivex.dbwithin a class that's auto-loaded in an__init__.pyfile.The nature of this module means that none of it's contents are auto-loaded / aliased using
__init__.pymodule constructor files. This shouldn't be a problem for most people though, as the functions/classes etc. within the module are primarily only useful for certain cache adapter classes, rather than intended for use by the users ofprivex-helpers(though there's nothing stopping you from importing things frompost_depsin your own project).sqlite_cache_set_dbfolderandsqlite_cache_set_dbnameare two module level functions that are intended for use by users. These functions allow you to quickly override theDEFAULT_DB_FOLDERand/orDEFAULT_DB_NAMEdynamically for both SqliteCacheManager and AsyncSqliteCacheManager.SqliteCacheResultis a namedtuple that represents a row returned when querying thepvcachetable within an SQLite cache database_SQManagerBaseis a mix-in class used by bothSqliteCacheManagerandAsyncSqliteCacheManager, containing code which is used by both classes.SqliteCacheManageris a child class ofSqliteWrapper, designed to provide easier interaction with an SQLite3 cache database, including automatic creation of the database file, and thepvcachetable within it. This class is intended for use byprivex.helpers.cache.SqliteCacheAsyncSqliteCacheManageris a child class ofSqliteAsyncWrapper, and is simply an AsyncIO version ofSqliteCacheManager. This class is intended for use byprivex.helpers.cache.asyncx.AsyncSqliteCache
privex.helpers.plugins
- Added
HAS_PRIVEX_DBattribute, for tracking whether theprivex-dblibrary is available for use. - Added
clean_threadstoreto__all__- seems I forgot to add it previously.
privex.helpers.settings
- Added
SQLITE_APP_DB_NAMEwhich can also be controlled via an env var of the same name - allowing you to adjust the base of the default DB filename for the SQLite3 cache adapters. - Added
SQLITE_APP_DB_FOLDER(can also be controlled via env) - similar to the DB_NAME attribute, controls the default base folder used by the SQLite3 cache adapters.