3.1.0 - Added SqliteCache + AsyncSqliteCache, plus minor fixes in privex.helpers.plugin
privex.helpers.cache
-
Added
SqliteCache
module, containing the synchronous cache adapterSqliteCache
which uses an Sqlite3 database for persistent cache storage without the need for any extra system service (unlike the memcached / redis adapters) -
Added
asyncx.AsyncSqliteCache
module, containing the AsyncIO cache adapterAsyncSqliteCache
, which is simply an AsyncIO version ofSqliteCache
using theaiosqlite
library.- 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_deps
module, 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-db
package, and theprivex-db
package imports various things fromprivex.helpers
causing a recursive import issue if we loadprivex.db
within a class that's auto-loaded in an__init__.py
file.The nature of this module means that none of it's contents are auto-loaded / aliased using
__init__.py
module 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_deps
in your own project).sqlite_cache_set_dbfolder
andsqlite_cache_set_dbname
are two module level functions that are intended for use by users. These functions allow you to quickly override theDEFAULT_DB_FOLDER
and/orDEFAULT_DB_NAME
dynamically for both SqliteCacheManager and AsyncSqliteCacheManager.SqliteCacheResult
is a namedtuple that represents a row returned when querying thepvcache
table within an SQLite cache database_SQManagerBase
is a mix-in class used by bothSqliteCacheManager
andAsyncSqliteCacheManager
, containing code which is used by both classes.SqliteCacheManager
is a child class ofSqliteWrapper
, designed to provide easier interaction with an SQLite3 cache database, including automatic creation of the database file, and thepvcache
table within it. This class is intended for use byprivex.helpers.cache.SqliteCache
AsyncSqliteCacheManager
is 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_DB
attribute, for tracking whether theprivex-db
library is available for use. - Added
clean_threadstore
to__all__
- seems I forgot to add it previously.
privex.helpers.settings
- Added
SQLITE_APP_DB_NAME
which 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.