Redis#

The Redis module provides a Redis-based version of the DBContextStorage class. This class is used to store and retrieve context data in a Redis. It allows Chatsky to easily store and retrieve context data in a format that is highly scalable and easy to work with.

Redis is an open-source, in-memory data structure store that is known for its high performance and scalability. It stores data in key-value pairs and supports a variety of data structures such as strings, hashes, lists, sets, and more. Additionally, Redis can be used as a cache, message broker, and database, making it a versatile and powerful choice for data storage and management.

class RedisContextStorage(path)[source]#

Bases: DBContextStorage

Implements DBContextStorage with redis as the database backend.

Parameters:

path (str) – Database URI string. Example: redis://user:password@host:port.

contains_async(key)[source]#

Asynchronous method for finding whether any Context is stored with given key.

Parameters:

key (Hashable) – Hashable key used to check if Context instance is stored.

Return type:

bool

Returns:

True if there is Context accessible by given key, False otherwise.

set_item_async(key, value)[source]#

Asynchronous method for storing Context.

Parameters:
  • key (Hashable) – Hashable key used to store Context instance.

  • value (Context) – Context to store.

get_item_async(key)[source]#

Asynchronous method for accessing stored Context.

Parameters:

key (Hashable) – Hashable key used to store Context instance.

Return type:

Context

Returns:

The stored context, associated with the given key.

del_item_async(key)[source]#

Asynchronous method for removing stored Context.

Parameters:

key (Hashable) – Hashable key used to identify Context instance for deletion.

len_async()[source]#

Asynchronous method for retrieving number of stored Contexts.

Return type:

int

Returns:

The number of stored Contexts.

clear_async()[source]#

Asynchronous method for clearing context storage, removing all the stored Contexts.