__init__

AsyncSqliteCache.__init__(db_file: str = None, memory_persist=False, use_pickle: bool = None, connection_kwargs: dict = None, *args, **kwargs)[source]

AsyncSqliteCache uses an auto-generated database filename / path by default, based on the name of the currently running script ( retrieved from sys.argv[0] ), allowing for persistent caching - without any manual configuration of the adapter, nor the requirement for any running background services such as redis / memcached.

Parameters
  • db_file (str) – (Optional) Name of / path to Sqlite3 database file to create/use for the cache.

  • memory_persist (bool) – Use a shared in-memory database, which can be accessed by other instances of this class (in this process) - which is cleared after all memory connections are closed. Shortcut for db_file='file::memory:?cache=shared'

  • use_pickle (bool) – (Default: True) Use the built-in pickle to serialise values before storing in Sqlite3, and un-serialise when loading from Sqlite3

  • connection_kwargs (dict) – (Optional) Additional / overriding kwargs to pass to sqlite3.connect() when AsyncSqliteCacheManager initialises it’s sqlite3 connection.

  • purge_every (int) – (Default: 300) Expired + abandoned cache records are purged using the DB manager method AsyncSqliteCacheManager.purge_expired() during get() / set() calls. To avoid performance issues, the actual AsyncSqliteCacheManager.purge_expired() method is only called if at least purge_every seconds have passed since the last purge was triggered ( last_purged_expired )