Skip to content

Commit 0473556

Browse files
Merge pull request #2552 from redis/DOC-6107-ioredis-section
DOC-6107 started ioredis client guide
2 parents a0c73f3 + b09a340 commit 0473556

File tree

12 files changed

+148
-5
lines changed

12 files changed

+148
-5
lines changed

build/components/example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
PREFIXES = {
2424
'python': '#',
2525
'node.js': '//',
26+
'ioredis': '//',
2627
'java': '//',
2728
'java-sync': '//',
2829
'java-async': '//',

build/local_examples.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,20 @@ def get_client_name_from_language(language: str) -> str:
5959
def get_client_name_from_language_and_path(language: str, path: str) -> str:
6060
"""Get client name from language with path-based overrides.
6161
62+
For JavaScript (.js) files, override based on path substrings:
63+
- If 'ioredis' in path -> ioredis
64+
- Otherwise -> Node.js
65+
6266
For Java (.java) files, override based on path substrings:
6367
- If 'lettuce-sync' in path -> Lettuce-Sync
6468
- If 'lettuce-async' in path -> Java-Async
6569
- If 'lettuce-reactive' in path -> Java-Reactive
6670
6771
Substring checks are case-sensitive and can appear anywhere in the path.
6872
"""
73+
if language == 'node.js':
74+
if 'ioredis' in path:
75+
return 'ioredis'
6976
if language == 'java':
7077
if 'lettuce-sync' in path:
7178
return 'Lettuce-Sync'

config.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ tagManagerId = "GTM-TKZ6J9R"
4646
gitHubRepo = "https://github.com/redis/docs"
4747

4848
# Display and sort order for client examples
49-
clientsExamples = ["Python", "Node.js", "Java-Sync", "Lettuce-Sync", "Java-Async", "Java-Reactive", "Go", "C", "C#-Sync", "C#-Async", "RedisVL", "PHP", "Rust-Sync", "Rust-Async"]
49+
clientsExamples = ["Python", "Node.js", "ioredis", "Java-Sync", "Lettuce-Sync", "Java-Async", "Java-Reactive", "Go", "C", "C#-Sync", "C#-Async", "RedisVL", "PHP", "Rust-Sync", "Rust-Async"]
5050
searchService = "/convai/api/search-service"
5151
ratingsService = "/docusight/api/rate/docs"
5252

@@ -61,6 +61,7 @@ rdi_current_version = "1.15.1"
6161
[params.clientsConfig]
6262
"Python"={quickstartSlug="redis-py"}
6363
"Node.js"={quickstartSlug="nodejs"}
64+
"ioredis"={quickstartSlug="ioredis"}
6465
"Java-Sync"={quickstartSlug="jedis"}
6566
"Lettuce-Sync"={quickstartSlug="lettuce"}
6667
"Java-Async"={quickstartSlug="lettuce"}

content/develop/clients/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ for eight main languages:
3030
| [Python](https://www.python.org/) | [`RedisVL`](https://github.com/redis/redis-vl-python) |[RedisVL guide]({{< relref "/develop/ai/redisvl" >}}) | Yes
3131
| [C#/.NET](https://learn.microsoft.com/en-us/dotnet/csharp/) | [`NRedisStack`](https://github.com/redis/NRedisStack) |[`NRedisStack` guide]({{< relref "/develop/clients/dotnet" >}}) | Yes |
3232
| [JavaScript](https://nodejs.org/en) | [`node-redis`](https://github.com/redis/node-redis) | [`node-redis` guide]({{< relref "/develop/clients/nodejs" >}}) | Yes |
33+
| [JavaScript](https://nodejs.org/en) | [`ioredis`](https://github.com/redis/ioredis) | [`ioredis` guide]({{< relref "/develop/clients/ioredis" >}}) | Yes |
3334
| [Java](https://www.java.com/en/) | [`Jedis`](https://github.com/redis/jedis) | [`Jedis` guide]({{< relref "/develop/clients/jedis" >}}) | Yes |
3435
| [Java](https://www.java.com/en/) | [`Lettuce`](https://github.com/redis/lettuce) | [`Lettuce` guide]({{< relref "/develop/clients/lettuce" >}}) | Yes |
3536
| [Go](https://go.dev/) | [`go-redis`](https://github.com/redis/go-redis) | [`go-redis` guide]({{< relref "/develop/clients/go" >}}) | Yes |
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
categories:
3+
- docs
4+
- develop
5+
- stack
6+
- oss
7+
- rs
8+
- rc
9+
- oss
10+
- kubernetes
11+
- clients
12+
description: Connect your Node.js/JavaScript application to a Redis database
13+
linkTitle: ioredis (JavaScript)
14+
title: ioredis guide (JavaScript)
15+
weight: 5
16+
---
17+
18+
[`ioredis`](https://github.com/redis/ioredis) is a Redis client for Node.js/JavaScript.
19+
The sections below explain how to install `ioredis` and connect your application
20+
to a Redis database.
21+
22+
{{< note >}}Redis actively maintains and supports `ioredis` since it is in widespread use, but
23+
for new projects, we recommend using our newer Node.js client
24+
[`node-redis`]({{< relref "/develop/clients/nodejs" >}}). See
25+
[Migrate from ioredis]({{< relref "/develop/clients/nodejs/migration" >}})
26+
if you are interested in converting an existing `ioredis` project to `node-redis`.
27+
{{< /note >}}
28+
29+
`ioredis` requires a running Redis server. See [here]({{< relref "/operate/oss_and_stack/install/" >}}) for Redis Open Source installation instructions.
30+
31+
## Install
32+
33+
To install `ioredis`, run:
34+
35+
```bash
36+
npm install ioredis
37+
```
38+
39+
## Connect and test
40+
41+
Connect to localhost on port 6379.
42+
43+
{{< clients-example set="landing" step="connect" lang_filter="ioredis" >}}
44+
{{< /clients-example >}}
45+
46+
Store and retrieve a simple string.
47+
48+
{{< clients-example set="landing" step="set_get_string" lang_filter="ioredis" >}}
49+
{{< /clients-example >}}
50+
51+
Store and retrieve a map.
52+
53+
{{< clients-example set="landing" step="set_get_hash" lang_filter="ioredis" >}}
54+
{{< /clients-example >}}
55+
56+
When you have finished using a connection, close it with `client.quit()`.
57+
58+
{{< clients-example set="landing" step="close" lang_filter="ioredis" >}}
59+
{{< /clients-example >}}
60+
61+
## More information
62+
63+
The [Github repository](https://github.com/redis/ioredis) has useful
64+
information, including [API docs](https://redis.github.io/ioredis/index.html)
65+
and a set of [code examples](https://github.com/redis/ioredis/tree/main/examples).

content/develop/clients/nodejs/_index.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@ title: node-redis guide (JavaScript)
1616
weight: 4
1717
---
1818

19-
[node-redis](https://github.com/redis/node-redis) is the Redis client for Node.js/JavaScript.
19+
[`node-redis`](https://github.com/redis/node-redis) is the Redis client for Node.js/JavaScript.
2020
The sections below explain how to install `node-redis` and connect your application
2121
to a Redis database.
2222

23+
{{< note >}}node-redis is the recommended client library for Node.js/JavaScript,
24+
but we also support and document our older JavaScript client
25+
[`ioredis`]({{< relref "/develop/clients/ioredis" >}}). See
26+
[Migrate from ioredis]({{< relref "/develop/clients/nodejs/migration" >}})
27+
if you are interested in converting an existing `ioredis` project to `node-redis`.
28+
{{< /note >}}
29+
2330
`node-redis` requires a running Redis server. See [here]({{< relref "/operate/oss_and_stack/install/" >}}) for Redis Open Source installation instructions.
2431

2532
You can also access Redis with an object-mapping client interface. See

content/develop/clients/nodejs/migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ title: Migrate from ioredis
1515
weight: 10
1616
---
1717

18-
Redis previously recommended the [`ioredis`](https://github.com/redis/ioredis)
18+
Redis previously recommended the [`ioredis`]({{< relref "/develop/clients/ioredis" >}})
1919
client library for development with [Node.js](https://nodejs.org/en),
2020
but this library is now deprecated in favor of
2121
[`node-redis`]({{< relref "/develop/clients/nodejs" >}}). This guide

data/components/index.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"nredisstack_async",
1212
"go_redis",
1313
"node_redis",
14+
"ioredis",
1415
"php",
1516
"redis_py",
1617
"jedis",

data/components/ioredis.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"id": "ioredis",
3+
"type": "client",
4+
"name": "ioredis",
5+
"language": "Node.js",
6+
"label": "ioredis",
7+
"repository": {
8+
"git_uri": "https://github.com/luin/ioredis"
9+
},
10+
"examples": {
11+
"git_uri": "https://github.com/luin/ioredis",
12+
"path": "examples",
13+
"pattern": "*.js"
14+
}
15+
}
16+

layouts/partials/tabbed-clients-example.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,15 @@
6464
{{/* Extract binderId if it exists */}}
6565
{{ $binderId := index $example "binderId" }}
6666

67-
{{ $tabs = $tabs | append (dict "title" $client "language" $client "quickstartSlug" $quickstartSlug "content" $content "sourceUrl" (index $example "sourceUrl") "binderId" $binderId) }}
67+
{{/* Map display names for clients */}}
68+
{{ $displayName := $client }}
69+
{{ if eq $client "Node.js" }}
70+
{{ $displayName = "JavaScript (node-redis)" }}
71+
{{ else if eq $client "ioredis" }}
72+
{{ $displayName = "JavaScript (ioredis)" }}
73+
{{ end }}
74+
75+
{{ $tabs = $tabs | append (dict "title" $client "displayName" $displayName "language" $client "quickstartSlug" $quickstartSlug "content" $content "sourceUrl" (index $example "sourceUrl") "binderId" $binderId) }}
6876
{{ end }}
6977
{{ end }}
7078

0 commit comments

Comments
 (0)