이 문서는 Upstash redis key-value stores 시작하기를 도와드립니다. 모든 UpstashRedisByteStore 기능 및 구성에 대한 자세한 문서는 API reference를 참조하세요.

Overview

UpstashRedisStoreUpstash에서 호스팅하는 Redis 인스턴스에 모든 것을 저장하는 ByteStore의 구현입니다. 대신 기본 RedisStore를 사용하려면 이 가이드를 참조하세요.

Integration details

ClassPackageLocalJS supportDownloadsVersion
UpstashRedisByteStorelangchain-communityPyPI - DownloadsPyPI - Version

Setup

먼저 Upstash 계정에 가입해야 합니다. 다음으로 연결할 Redis 데이터베이스를 생성해야 합니다.

Credentials

데이터베이스를 생성한 후, 데이터베이스 URL(https://를 잊지 마세요!)과 token을 가져오세요:
from getpass import getpass

URL = getpass("Enter your Upstash URL")
TOKEN = getpass("Enter your Upstash REST token")

Installation

LangChain Upstash integration은 langchain-community 패키지에 포함되어 있습니다. peer dependency로 upstash-redis 패키지도 설치해야 합니다:
pip install -qU langchain-community upstash-redis

Instantiation

이제 byte store를 인스턴스화할 수 있습니다:
from langchain_community.storage import UpstashRedisByteStore
from upstash_redis import Redis

redis_client = Redis(url=URL, token=TOKEN)
kv_store = UpstashRedisByteStore(client=redis_client, ttl=None, namespace="test-ns")

Usage

mset 메서드를 사용하여 다음과 같이 key 아래에 데이터를 설정할 수 있습니다:
kv_store.mset(
    [
        ["key1", b"value1"],
        ["key2", b"value2"],
    ]
)

kv_store.mget(
    [
        "key1",
        "key2",
    ]
)
[b'value1', b'value2']
그리고 mdelete 메서드를 사용하여 데이터를 삭제할 수 있습니다:
kv_store.mdelete(
    [
        "key1",
        "key2",
    ]
)

kv_store.mget(
    [
        "key1",
        "key2",
    ]
)
[None, None]

API reference

모든 UpstashRedisByteStore 기능 및 구성에 대한 자세한 문서는 API reference를 참조하세요: python.langchain.com/api_reference/community/storage/langchain_community.storage.upstash_redis.UpstashRedisByteStore.html
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I