|
.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, typing.Any default=None, str|None ctx=None) |
| Iterator[tuple[str, typing.Any]] | pairs (self, str ctx) |
| ExpireCacheStats | state (self) |
| Public Member Functions inherited from searx.sqlitedb.SQLiteAppl | |
| __init__ (self, str db_url) | |
| sqlite3.Connection | connect (self) |
| register_functions (self, sqlite3.Connection conn) | |
| sqlite3.Connection | DB (self) |
| create_schema (self, sqlite3.Connection conn) | |
| Public Member Functions inherited from searx.cache.ExpireCache | |
| bytes | serialize (self, typing.Any value) |
| typing.Any | deserialize (self, bytes value) |
| str | secret_hash (self, str|bytes name) |
Public Attributes | |
| ExpireCacheCfg | cfg = cfg |
| next_maintenance_time | |
| table_names | |
| Public Attributes inherited from searx.sqlitedb.SQLiteAppl | |
| str | db_url = db_url |
| SQLiteProperties | properties = SQLiteProperties(db_url) |
Static Public Attributes | |
| str | CACHE_TABLE_PREFIX = "CACHE-TABLE" |
| Static Public Attributes inherited from searx.sqlitedb.SQLiteAppl | |
| dict | DDL_CREATE_TABLES = {} |
| int | DB_SCHEMA = 1 |
| dict | SQLITE_THREADING_MODE |
| str | SQLITE_JOURNAL_MODE = "WAL" |
| dict | SQLITE_CONNECT_ARGS |
| Static Public Attributes inherited from searx.cache.ExpireCache | |
| str | hash_token = "hash_token" |
Additional Inherited Members | |
| Static Public Member Functions inherited from searx.cache.ExpireCache | |
| "ExpireCacheSQLite" | build_cache (ExpireCacheCfg cfg) |
| str | normalize_name (str name) |
| Protected Member Functions inherited from searx.sqlitedb.SQLiteAppl | |
| _compatibility (self) | |
| sqlite3.Connection | _connect (self) |
| Protected Attributes inherited from searx.sqlitedb.SQLiteAppl | |
| bool | _init_done = False |
| sqlite3.Connection|None | _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 230 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 284 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, | ||
| typing.Any | 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 375 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 239 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(), init(), searx.data.currencies.CurrenciesDB.iso4217_to_name(), searx.data.currencies.CurrenciesDB.name_to_iso4217(), and searx.data.tracker_patterns.TrackerPatternsDB.rules().
| 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 254 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 327 of file cache.py.
References searx.botdetection.config.Config.cfg, cfg, and searx.sqlitedb.SQLiteAppl.properties.
| Iterator[tuple[str, typing.Any]] searx.cache.ExpireCacheSQLite.pairs | ( | self, | |
| str | ctx ) |
Iterate over key/value pairs from table given by argument ``ctx``. If ``ctx`` argument is ``None`` (the default), a table name is generated from the :py:obj:`ExpireCacheCfg.name`.
Definition at line 398 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.
| 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 334 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 412 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 312 of file cache.py.
References DB.
| searx.cache.ExpireCacheSQLite.truncate_tables | ( | self, | |
| list[str] | table_names ) |
Definition at line 318 of file cache.py.
References searx.sqlitedb.SQLiteAppl.connect().
|
static |
| ExpireCacheCfg searx.cache.ExpireCacheSQLite.cfg = cfg |
Definition at line 234 of file cache.py.
Referenced by get(), init(), next_maintenance_time(), searx.favicons.cache.FaviconCacheSQLite.next_maintenance_time(), pairs(), searx.cache.ExpireCache.secret_hash(), set(), and searx.favicons.cache.FaviconCacheSQLite.set().
| searx.cache.ExpireCacheSQLite.next_maintenance_time |
Definition at line 256 of file cache.py.
Referenced by searx.favicons.cache.FaviconCacheSQLite.set().
| searx.cache.ExpireCacheSQLite.table_names |