.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
valkeydb.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""Providing a Valkey database for the botdetection methods."""
3
4from __future__ import annotations
5
6import valkey
7
8__all__ = ["set_valkey_client", "get_valkey_client"]
9
10CLIENT: valkey.Valkey | None = None
11"""Global Valkey DB connection (Valkey client object)."""
12
13
14def set_valkey_client(valkey_client: valkey.Valkey):
15 global CLIENT # pylint: disable=global-statement
16 CLIENT = valkey_client
17
18
19def get_valkey_client() -> valkey.Valkey:
20 if CLIENT is None:
21 raise ValueError("No connection to the Valkey database has been established.")
22 return CLIENT
set_valkey_client(valkey.Valkey valkey_client)
Definition valkeydb.py:14
valkey.Valkey get_valkey_client()
Definition valkeydb.py:19