-
Notifications
You must be signed in to change notification settings - Fork 15.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "raw", | ||
"metadata": {}, | ||
"source": [ | ||
"---\n", | ||
"sidebar_label: Upstash Redis\n", | ||
"---" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# UpstashRedisByteStore\n", | ||
"\n", | ||
"The `UpstashRedisStore` is an implementation of `ByteStore` that stores everything in your Upstash-hosted Redis instance.\n", | ||
"\n", | ||
"To use the base `RedisStore` instead, see [this guide](./redis)\n", | ||
"\n", | ||
"To configure Upstash Redis, follow our [Upstash guide](/docs/integrations/providers/upstash)." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"!pip install upstash-redis" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[b'v1', b'v2']\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from langchain.storage import UpstashRedisByteStore\n", | ||
"from upstash_redis import Redis\n", | ||
"\n", | ||
"URL = \"<UPSTASH_REDIS_REST_URL>\"\n", | ||
"TOKEN = \"<UPSTASH_REDIS_REST_TOKEN>\"\n", | ||
"\n", | ||
"redis_client = Redis(url=URL, token=TOKEN)\n", | ||
"store = UpstashRedisByteStore(client=redis_client, ttl=None, namespace=\"test-ns\")\n", | ||
"\n", | ||
"store.mset([(\"k1\", b\"v1\"), (\"k2\", b\"v2\")])\n", | ||
"print(store.mget([\"k1\", \"k2\"]))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": ".venv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters