Skip to content

Commit

Permalink
redis
Browse files Browse the repository at this point in the history
  • Loading branch information
efriis committed Dec 6, 2023
1 parent 600e9d7 commit e7774ed
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 464 deletions.
18 changes: 18 additions & 0 deletions docs/docs/integrations/providers/redis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ Install the Python SDK:
pip install redis
```

To run Redis locally, you can use Docker:

```bash
docker run --name langchain-redis -d -p 6379:6379 redis redis-server --save 60 1 --loglevel warning
```

To stop the container:

```bash
docker stop langchain-redis
```

And to start it again:

```bash
docker start langchain-redis
```

## Wrappers

All wrappers need a redis url connection string to connect to the database support either a stand alone Redis server
Expand Down
28 changes: 19 additions & 9 deletions docs/docs/integrations/stores/redis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,33 @@
"metadata": {},
"source": [
"---\n",
"sidebar_label: In Memory\n",
"sidebar_position: 2\n",
"sidebar_label: Redis\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# InMemoryByteStore\n",
"# RedisStore\n",
"\n",
"The `InMemoryByteStore` is a non-persistent implementation of `ByteStore` that stores everything in a Python dictionary."
"The `RedisStore` is an implementation of `ByteStore` that stores everything in your Redis instance.\n",
"\n",
"To configure Redis, follow our [Redis guide](/docs/integrations/providers/redis)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install redis"
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand All @@ -33,12 +43,12 @@
}
],
"source": [
"from langchain.storage import InMemoryByteStore\n",
"from langchain.storage import RedisStore\n",
"\n",
"store = InMemoryByteStore()\n",
"store = RedisStore(redis_url=\"redis://localhost:6379\")\n",
"\n",
"store.mset([('k1', b'v1'), ('k2', b'v2')])\n",
"print(store.mget(['k1', 'k2']))"
"store.mset([(\"k1\", b\"v1\"), (\"k2\", b\"v2\")])\n",
"print(store.mget([\"k1\", \"k2\"]))"
]
},
{
Expand Down
Loading

0 comments on commit e7774ed

Please sign in to comment.