Key Value Store Module
key_value_store.key_value_api
TcEx Framework Key Value API Module
- class tcex.key_value_store.key_value_api.KeyValueApi(session: object)[source]
Bases:
KeyValueABC
TcEx Key Value API Module.
- Parameters:
session – A configured requests session for TC API (tcex.session).
- create(context: str, key: str, value: Any) str [source]
Create key/value pair in remote KV store.
- Parameters:
context – A specific context for the create.
key – The key to create in remote KV store.
value – The value to store in remote KV store.
- Returns:
The response from the API call.
- Return type:
(string)
key_value_store.key_value_redis
TcEx Framework Key Value Redis Module
- class tcex.key_value_store.key_value_redis.KeyValueRedis(redis_client: RedisClient)[source]
Bases:
KeyValueABC
TcEx Key Value Redis Module.
- Parameters:
redis_client (redis.Client) – An instance of redis client.
- create(context: str, key: str, value: Any)[source]
Create key/value pair in Redis.
- Parameters:
context – A specific context for the create.
key (str) – The field name (key) for the kv pair in Redis.
value (any) – The value for the kv pair in Redis.
- Returns:
The response from Redis.
- Return type:
str
- delete(context: str, key: str) str [source]
Alias for hdel method.
- Parameters:
context – A specific context for the create.
key – The field name (key) for the kv pair in Redis.
- Returns:
The response from Redis.
- Return type:
str
- get_all(context: Optional[str]) Any [source]
Return the contents for a given context.
- Parameters:
context – the context to return
- hget(context: str, key: str) Optional[bytes] [source]
Read data from redis for the provided key.
This method will not convert the retrieved data (like read() does).
- Parameters:
context – A specific context for the create.
key – The field name (key) for the kv pair in Redis.
- Returns:
the raw value from redis, if any
- Return type:
Optional[bytes]
key_value_store.redis_client
TcEx Framework Module
- class tcex.key_value_store.redis_client.RedisClient(host: str = 'localhost', port: int = 6379, db: int = 0, blocking_pool: bool = False, **kwargs)[source]
Bases:
object
A shared REDIS client connection using a Connection Pool.
Initialize a single shared redis.connection.ConnectionPool. For a full list of kwargs see https://redis-py.readthedocs.io/en/latest/#redis.Connection.
- Parameters:
host – The Redis host. Defaults to localhost.
port – The Redis port. Defaults to 6379.
db – The Redis db. Defaults to 0.
blocking_pool – Use BlockingConnectionPool instead of ConnectionPool.
errors (str, kwargs) – The REDIS errors policy (e.g. strict).
max_connections (int, kwargs) – The maximum number of connections to REDIS.
password (str, kwargs) – The REDIS password.
socket_timeout (int, kwargs) – The REDIS socket timeout.
timeout (int, kwargs) – The REDIS Blocking Connection Pool timeout value.
- client
Return an instance of redis.client.Redis.