KV Storage
- class llama_index.storage.kvstore.MongoDBKVStore(mongo_client: Any, uri: Optional[str] = None, host: Optional[str] = None, port: Optional[int] = None, db_name: Optional[str] = None)
MongoDB Key-Value store.
- Parameters
mongo_client (Any) – MongoDB client
uri (Optional[str]) – MongoDB URI
host (Optional[str]) – MongoDB host
port (Optional[int]) – MongoDB port
db_name (Optional[str]) – MongoDB database name
- delete(key: str, collection: str = 'data') bool
Delete a value from the store.
- Parameters
key (str) – key
collection (str) – collection name
- classmethod from_host_and_port(host: str, port: int, db_name: Optional[str] = None) MongoDBKVStore
Load a MongoDBKVStore from a MongoDB host and port.
- Parameters
host (str) – MongoDB host
port (int) – MongoDB port
db_name (Optional[str]) – MongoDB database name
- classmethod from_uri(uri: str, db_name: Optional[str] = None) MongoDBKVStore
Load a MongoDBKVStore from a MongoDB URI.
- Parameters
uri (str) – MongoDB URI
db_name (Optional[str]) – MongoDB database name
- get(key: str, collection: str = 'data') Optional[dict]
Get a value from the store.
- Parameters
key (str) – key
collection (str) – collection name
- get_all(collection: str = 'data') Dict[str, dict]
Get all values from the store.
- Parameters
collection (str) – collection name
- put(key: str, val: dict, collection: str = 'data') None
Put a key-value pair into the store.
- Parameters
key (str) – key
val (dict) – value
collection (str) – collection name
- class llama_index.storage.kvstore.SimpleKVStore(data: Optional[Dict[str, Dict[str, dict]]] = None)
Simple in-memory Key-Value store.
- Parameters
data (Optional[DATA_TYPE]) – data to initialize the store with
- delete(key: str, collection: str = 'data') bool
Delete a value from the store.
- classmethod from_dict(save_dict: dict) SimpleKVStore
Load a SimpleKVStore from dict.
- classmethod from_persist_path(persist_path: str, fs: Optional[AbstractFileSystem] = None) SimpleKVStore
Load a SimpleKVStore from a persist path and filesystem.
- get(key: str, collection: str = 'data') Optional[dict]
Get a value from the store.
- get_all(collection: str = 'data') Dict[str, dict]
Get all values from the store.
- persist(persist_path: str, fs: Optional[AbstractFileSystem] = None) None
Persist the store.
- put(key: str, val: dict, collection: str = 'data') None
Put a key-value pair into the store.
- to_dict() dict
Save the store as dict.