.oO SearXNG Developer Documentation Oo.
|
Public Member Functions | |
__init__ (self, ExpireCacheCfg cfg) | |
bool | init (self, sqlite3.Connection conn) |
bool | maintenance (self, bool force=False, bool truncate=False) |
bool | create_table (self, str table) |
list[str] | table_names (self) |
truncate_tables (self, list[str] table_names) | |
int | next_maintenance_time (self) |
bool | set (self, str key, typing.Any value, int|None expire, str|None ctx=None) |
typing.Any | get (self, str key, default=None, str|None ctx=None) |
ExpireCacheStats | state (self) |
![]() | |
__init__ (self, db_url) | |
sqlite3.Connection | connect (self) |
register_functions (self, conn) | |
sqlite3.Connection | DB (self) |
create_schema (self, sqlite3.Connection conn) | |
![]() | |
bytes | serialize (self, typing.Any value) |
typing.Any | deserialize (self, bytes value) |
str | secret_hash (self, str|bytes name) |
Public Attributes | |
cfg = cfg | |
next_maintenance_time | |
table_names | |
![]() | |
db_url = db_url | |
properties = SQLiteProperties(db_url) | |
Static Public Attributes | |
str | CACHE_TABLE_PREFIX = "CACHE-TABLE-" |
![]() | |
dict | DDL_CREATE_TABLES = {} |
int | DB_SCHEMA = 1 |
dict | SQLITE_THREADING_MODE |
str | SQLITE_JOURNAL_MODE = "WAL" |
dict | SQLITE_CONNECT_ARGS |
![]() | |
ExpireCacheCfg | hash_token = "hash_token" |
Additional Inherited Members | |
![]() | |
ExpireCache | build_cache (ExpireCacheCfg cfg) |
str | normalize_name (str name) |
![]() | |
_compatibility (self) | |
sqlite3.Connection | _connect (self) |
![]() | |
bool | _init_done = False |
_DB = None | |
Cache that manages key/value pairs in a SQLite DB. The DB model in the SQLite DB is implemented in abstract class :py:obj:`SQLiteAppl <searx.sqlitedb.SQLiteAppl>`. The following configurations are required / supported: - :py:obj:`ExpireCacheCfg.db_url` - :py:obj:`ExpireCacheCfg.MAXHOLD_TIME` - :py:obj:`ExpireCacheCfg.MAINTENANCE_PERIOD` - :py:obj:`ExpireCacheCfg.MAINTENANCE_MODE`
searx.cache.ExpireCacheSQLite.__init__ | ( | self, | |
ExpireCacheCfg | cfg ) |
An instance of the SQLite expire cache is build up from a :py:obj:`config <ExpireCacheCfg>`.
Definition at line 231 of file cache.py.
bool searx.cache.ExpireCacheSQLite.create_table | ( | self, | |
str | table ) |
Create DB ``table`` if it has not yet been created, no recreates are initiated if the table already exists.
Definition at line 285 of file cache.py.
References searx.sqlitedb.SQLiteAppl.connect(), searx.sqlitedb.SQLiteAppl.properties, set(), and table_names.
Referenced by set().
typing.Any searx.cache.ExpireCacheSQLite.get | ( | self, | |
str | key, | ||
default = None, | |||
str | None | ctx = None ) |
Get value of ``key`` from table given by argument ``ctx``. If ``ctx`` argument is ``None`` (the default), a table name is generated from the :py:obj:`ExpireCacheCfg.name`. If ``key`` not exists (in table), the ``default`` value is returned.
Reimplemented from searx.cache.ExpireCache.
Definition at line 376 of file cache.py.
References searx.botdetection.config.Config.cfg, cfg, DB, searx.cache.ExpireCache.deserialize(), searx.cache.ExpireCache.maintenance(), searx.cache.ExpireCache.normalize_name(), and table_names.
Referenced by searx.result_types._base.LegacyResult.__init__(), searx.result_types._base.LegacyResult.defaults_from(), and searx.answerers._core.AnswerStorage.register().
bool searx.cache.ExpireCacheSQLite.init | ( | self, | |
sqlite3.Connection | conn ) |
Initializes the DB schema and properties, is only executed once even if called several times. If the initialization has not yet taken place, it is carried out and a `True` is returned to the caller at the end. If the initialization has already been carried out in the past, `False` is returned.
Reimplemented from searx.sqlitedb.SQLiteAppl.
Definition at line 240 of file cache.py.
References searx.botdetection.config.Config.cfg, cfg, searx.cache.ExpireCache.hash_token, init(), searx.cache.ExpireCache.maintenance(), and searx.sqlitedb.SQLiteAppl.properties.
Referenced by searx.sqlitedb.SQLiteAppl.connect(), searx.sqlitedb.SQLiteAppl.DB(), and init().
bool searx.cache.ExpireCacheSQLite.maintenance | ( | self, | |
bool | force = False, | ||
bool | truncate = False ) |
Performs maintenance on the cache. ``force``: Maintenance should be carried out even if the maintenance interval has not yet been reached. ``truncate``: Truncate the entire cache, which is necessary, for example, if the password has changed.
Reimplemented from searx.cache.ExpireCache.
Definition at line 255 of file cache.py.
Referenced by searx.favicons.cache.FaviconCacheSQLite.set().
int searx.cache.ExpireCacheSQLite.next_maintenance_time | ( | self | ) |
Returns (unix epoch) time of the next maintenance.
Definition at line 328 of file cache.py.
References searx.botdetection.config.Config.cfg, cfg, and searx.sqlitedb.SQLiteAppl.properties.
bool searx.cache.ExpireCacheSQLite.set | ( | self, | |
str | key, | ||
typing.Any | value, | ||
int | None | expire, | ||
str | None | ctx = None ) |
Set key/value in DB table given by argument ``ctx``. If expire is unset the default is taken from :py:obj:`ExpireCacheCfg.MAXHOLD_TIME`. If ``ctx`` argument is ``None`` (the default), a table name is generated from the :py:obj:`ExpireCacheCfg.name`. If DB table does not exists, it will be created (on demand) by :py:obj:`self.create_table <ExpireCacheSQLite.create_table>`.
Reimplemented from searx.cache.ExpireCache.
Definition at line 335 of file cache.py.
References searx.botdetection.config.Config.cfg, cfg, create_table(), searx.cache.ExpireCache.maintenance(), searx.cache.ExpireCache.normalize_name(), and searx.cache.ExpireCache.serialize().
Referenced by create_table().
ExpireCacheStats searx.cache.ExpireCacheSQLite.state | ( | self | ) |
Returns a :py:obj:`ExpireCacheStats`, which provides information about the status of the cache.
Reimplemented from searx.cache.ExpireCache.
Definition at line 399 of file cache.py.
References DB, searx.cache.ExpireCache.deserialize(), and table_names.
list[str] searx.cache.ExpireCacheSQLite.table_names | ( | self | ) |
List of key/value tables already created in the DB.
Definition at line 313 of file cache.py.
References DB.
searx.cache.ExpireCacheSQLite.truncate_tables | ( | self, | |
list[str] | table_names ) |
Definition at line 319 of file cache.py.
References searx.sqlitedb.SQLiteAppl.connect().
|
static |
searx.cache.ExpireCacheSQLite.cfg = cfg |
Definition at line 235 of file cache.py.
Referenced by get(), init(), next_maintenance_time(), searx.favicons.cache.FaviconCacheSQLite.next_maintenance_time(), searx.cache.ExpireCache.secret_hash(), set(), and searx.favicons.cache.FaviconCacheSQLite.set().
searx.cache.ExpireCacheSQLite.next_maintenance_time |
Definition at line 257 of file cache.py.
Referenced by searx.favicons.cache.FaviconCacheSQLite.set().
searx.cache.ExpireCacheSQLite.table_names |
Definition at line 266 of file cache.py.
Referenced by create_table(), get(), and state().