Login
Back to bricks list
Introduction Version

KVStore

KVStore class representing a key-value object storage engine. This class allows serializing/deserializing huge objects on store.

Functions

__INIT__

Initialize self. See help(type(self)) for accurate signature.

Parameters:
NameTypeDefault valueDescription
full_file_pathstr
CHECK_BEFORE_READ
CHECK_BEFORE_WRITE
Parameters:
NameTypeDefault valueDescription
keystr
FILE_EXISTS
Return type:
bool
GENERATE_NEW_FILE

Generate a new eloty file in the directory of the kvstore

Return type:
Path
GET

Return the value for key if key is in the dictionary, else default.

Parameters:
NameTypeDefault valueDescription
keyAny
defaultAny
GET_FULL_PATH_WITHOUT_EXTENSION
Return type:
str
LOCK

Lock the kv store, it can no longer be modified. If a modification happens, it copies the file before updating the data, To copy the file is uses the _lock_copy_name

Parameters:
NameTypeDefault valueDescription
_lock_copy_file_pathstr
REMOVE

Remove the store

EMPTY - @classmethod

Create an new kv store and generate the file name automatically

Return type:
KVStore
FROM_FILENAME - @classmethod
Parameters:
NameTypeDefault valueDescription
file_namestr
Return type:
KVStore
GET_BASE_DIR - @classmethod
Return type:
str
GET_FULL_FILE_PATH - @classmethod
Parameters:
NameTypeDefault valueDescription
file_namestr
with_extensionbool True
Return type:
str