Pickle#
The Pickle module provides a pickle-based version of the DBContextStorage
class.
This class is used to store and retrieve context data in a pickle format.
It allows Chatsky to easily store and retrieve context data in a format that is efficient
for serialization and deserialization and can be easily used in python.
Pickle is a python library that allows to serialize and deserialize python objects. It is efficient and fast, but it is not recommended to use it to transfer data across different languages or platforms because it’s not cross-language compatible.
- class PickleContextStorage(path)[source]#
Bases:
DBContextStorage
Implements
DBContextStorage
with pickle as driver.- Parameters:
path (
str
) – Target file URI. Example: ‘pickle://file.pkl’.
- len_async()[source]#
Asynchronous method for retrieving number of stored Contexts.
- Return type:
int
- Returns:
The number of stored Contexts.
- 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:
- 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.
- 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.