Skip to content

Redis

RedisDocumentStore #

Bases: KVDocumentStore

Redis文档(Node)存储。

用于文档和节点对象的Redis存储。

Source code in llama_index/storage/docstore/redis/base.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class RedisDocumentStore(KVDocumentStore):
    """Redis文档(Node)存储。

    用于文档和节点对象的Redis存储。

    Args:
        redis_kvstore(RedisKVStore):Redis键值存储
        namespace(str):文档存储的命名空间"""

    def __init__(
        self,
        redis_kvstore: RedisKVStore,
        namespace: Optional[str] = None,
        batch_size: int = DEFAULT_BATCH_SIZE,
    ) -> None:
        """初始化一个RedisDocumentStore。"""
        super().__init__(redis_kvstore, namespace=namespace, batch_size=batch_size)
        # avoid conflicts with redis index store
        self._node_collection = f"{self._namespace}/doc"

    @classmethod
    def from_redis_client(
        cls,
        redis_client: Any,
        namespace: Optional[str] = None,
    ) -> "RedisDocumentStore":
        """从Redis客户端加载一个RedisDocumentStore。"""
        redis_kvstore = RedisKVStore.from_redis_client(redis_client=redis_client)
        return cls(redis_kvstore, namespace)

    @classmethod
    def from_host_and_port(
        cls,
        host: str,
        port: int,
        namespace: Optional[str] = None,
    ) -> "RedisDocumentStore":
        """从Redis主机和端口加载一个RedisDocumentStore。"""
        redis_kvstore = RedisKVStore.from_host_and_port(host, port)
        return cls(redis_kvstore, namespace)

from_redis_client classmethod #

from_redis_client(
    redis_client: Any, namespace: Optional[str] = None
) -> RedisDocumentStore

从Redis客户端加载一个RedisDocumentStore。

Source code in llama_index/storage/docstore/redis/base.py
28
29
30
31
32
33
34
35
36
@classmethod
def from_redis_client(
    cls,
    redis_client: Any,
    namespace: Optional[str] = None,
) -> "RedisDocumentStore":
    """从Redis客户端加载一个RedisDocumentStore。"""
    redis_kvstore = RedisKVStore.from_redis_client(redis_client=redis_client)
    return cls(redis_kvstore, namespace)

from_host_and_port classmethod #

from_host_and_port(
    host: str, port: int, namespace: Optional[str] = None
) -> RedisDocumentStore

从Redis主机和端口加载一个RedisDocumentStore。

Source code in llama_index/storage/docstore/redis/base.py
38
39
40
41
42
43
44
45
46
47
@classmethod
def from_host_and_port(
    cls,
    host: str,
    port: int,
    namespace: Optional[str] = None,
) -> "RedisDocumentStore":
    """从Redis主机和端口加载一个RedisDocumentStore。"""
    redis_kvstore = RedisKVStore.from_host_and_port(host, port)
    return cls(redis_kvstore, namespace)