Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/components/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
PREFIXES = {
'python': '#',
'node.js': '//',
'ioredis': '//',
'java': '//',
'java-sync': '//',
'java-async': '//',
Expand Down
7 changes: 7 additions & 0 deletions build/local_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,20 @@ def get_client_name_from_language(language: str) -> str:
def get_client_name_from_language_and_path(language: str, path: str) -> str:
"""Get client name from language with path-based overrides.

For JavaScript (.js) files, override based on path substrings:
- If 'ioredis' in path -> ioredis
- Otherwise -> Node.js

For Java (.java) files, override based on path substrings:
- If 'lettuce-sync' in path -> Lettuce-Sync
- If 'lettuce-async' in path -> Java-Async
- If 'lettuce-reactive' in path -> Java-Reactive

Substring checks are case-sensitive and can appear anywhere in the path.
"""
if language == 'node.js':
if 'ioredis' in path:
return 'ioredis'
if language == 'java':
if 'lettuce-sync' in path:
return 'Lettuce-Sync'
Expand Down
3 changes: 2 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ tagManagerId = "GTM-TKZ6J9R"
gitHubRepo = "https://github.com/redis/docs"

# Display and sort order for client examples
clientsExamples = ["Python", "Node.js", "Java-Sync", "Lettuce-Sync", "Java-Async", "Java-Reactive", "Go", "C", "C#-Sync", "C#-Async", "RedisVL", "PHP", "Rust-Sync", "Rust-Async"]
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"]
searchService = "/convai/api/search-service"
ratingsService = "/docusight/api/rate/docs"

Expand All @@ -61,6 +61,7 @@ rdi_current_version = "1.15.1"
[params.clientsConfig]
"Python"={quickstartSlug="redis-py"}
"Node.js"={quickstartSlug="nodejs"}
"ioredis"={quickstartSlug="ioredis"}
"Java-Sync"={quickstartSlug="jedis"}
"Lettuce-Sync"={quickstartSlug="lettuce"}
"Java-Async"={quickstartSlug="lettuce"}
Expand Down
1 change: 1 addition & 0 deletions content/develop/clients/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ for eight main languages:
| [Python](https://www.python.org/) | [`RedisVL`](https://github.com/redis/redis-vl-python) |[RedisVL guide]({{< relref "/develop/ai/redisvl" >}}) | Yes
| [C#/.NET](https://learn.microsoft.com/en-us/dotnet/csharp/) | [`NRedisStack`](https://github.com/redis/NRedisStack) |[`NRedisStack` guide]({{< relref "/develop/clients/dotnet" >}}) | Yes |
| [JavaScript](https://nodejs.org/en) | [`node-redis`](https://github.com/redis/node-redis) | [`node-redis` guide]({{< relref "/develop/clients/nodejs" >}}) | Yes |
| [JavaScript](https://nodejs.org/en) | [`ioredis`](https://github.com/redis/ioredis) | [`ioredis` guide]({{< relref "/develop/clients/ioredis" >}}) | Yes |
| [Java](https://www.java.com/en/) | [`Jedis`](https://github.com/redis/jedis) | [`Jedis` guide]({{< relref "/develop/clients/jedis" >}}) | Yes |
| [Java](https://www.java.com/en/) | [`Lettuce`](https://github.com/redis/lettuce) | [`Lettuce` guide]({{< relref "/develop/clients/lettuce" >}}) | Yes |
| [Go](https://go.dev/) | [`go-redis`](https://github.com/redis/go-redis) | [`go-redis` guide]({{< relref "/develop/clients/go" >}}) | Yes |
Expand Down
65 changes: 65 additions & 0 deletions content/develop/clients/ioredis/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
categories:
- docs
- develop
- stack
- oss
- rs
- rc
- oss
- kubernetes
- clients
description: Connect your Node.js/JavaScript application to a Redis database
linkTitle: ioredis (JavaScript)
title: ioredis guide (JavaScript)
weight: 5
---

[`ioredis`](https://github.com/redis/ioredis) is a Redis client for Node.js/JavaScript.
The sections below explain how to install `ioredis` and connect your application
to a Redis database.

{{< note >}}Redis actively maintains and supports `ioredis` since it is in widespread use, but
for new projects, we recommend using our newer Node.js client
[`node-redis`]({{< relref "/develop/clients/nodejs" >}}). See
[Migrate from ioredis]({{< relref "/develop/clients/nodejs/migration" >}})
if you are interested in converting an existing `ioredis` project to `node-redis`.
{{< /note >}}

`ioredis` requires a running Redis server. See [here]({{< relref "/operate/oss_and_stack/install/" >}}) for Redis Open Source installation instructions.

## Install

To install `ioredis`, run:

```bash
npm install ioredis
```

## Connect and test

Connect to localhost on port 6379.

{{< clients-example set="landing" step="connect" lang_filter="ioredis" >}}
{{< /clients-example >}}

Store and retrieve a simple string.

{{< clients-example set="landing" step="set_get_string" lang_filter="ioredis" >}}
{{< /clients-example >}}

Store and retrieve a map.

{{< clients-example set="landing" step="set_get_hash" lang_filter="ioredis" >}}
{{< /clients-example >}}

When you have finished using a connection, close it with `client.quit()`.

{{< clients-example set="landing" step="close" lang_filter="ioredis" >}}
{{< /clients-example >}}

## More information

The [Github repository](https://github.com/redis/ioredis) has useful
information, including [API docs](https://redis.github.io/ioredis/index.html)
and a set of [code examples](https://github.com/redis/ioredis/tree/main/examples).
9 changes: 8 additions & 1 deletion content/develop/clients/nodejs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@ title: node-redis guide (JavaScript)
weight: 4
---

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

{{< note >}}node-redis is the recommended client library for Node.js/JavaScript,
but we also support and document our older JavaScript client
[`ioredis`]({{< relref "/develop/clients/ioredis" >}}). See
[Migrate from ioredis]({{< relref "/develop/clients/nodejs/migration" >}})
if you are interested in converting an existing `ioredis` project to `node-redis`.
{{< /note >}}

`node-redis` requires a running Redis server. See [here]({{< relref "/operate/oss_and_stack/install/" >}}) for Redis Open Source installation instructions.

You can also access Redis with an object-mapping client interface. See
Expand Down
2 changes: 1 addition & 1 deletion content/develop/clients/nodejs/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ title: Migrate from ioredis
weight: 10
---

Redis previously recommended the [`ioredis`](https://github.com/redis/ioredis)
Redis previously recommended the [`ioredis`]({{< relref "/develop/clients/ioredis" >}})
client library for development with [Node.js](https://nodejs.org/en),
but this library is now deprecated in favor of
[`node-redis`]({{< relref "/develop/clients/nodejs" >}}). This guide
Expand Down
1 change: 1 addition & 0 deletions data/components/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"nredisstack_async",
"go_redis",
"node_redis",
"ioredis",
"php",
"redis_py",
"jedis",
Expand Down
16 changes: 16 additions & 0 deletions data/components/ioredis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"id": "ioredis",
"type": "client",
"name": "ioredis",
"language": "Node.js",
"label": "ioredis",
"repository": {
"git_uri": "https://github.com/luin/ioredis"
},
"examples": {
"git_uri": "https://github.com/luin/ioredis",
"path": "examples",
"pattern": "*.js"
}
}

10 changes: 9 additions & 1 deletion layouts/partials/tabbed-clients-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,15 @@
{{/* Extract binderId if it exists */}}
{{ $binderId := index $example "binderId" }}

{{ $tabs = $tabs | append (dict "title" $client "language" $client "quickstartSlug" $quickstartSlug "content" $content "sourceUrl" (index $example "sourceUrl") "binderId" $binderId) }}
{{/* Map display names for clients */}}
{{ $displayName := $client }}
{{ if eq $client "Node.js" }}
{{ $displayName = "JavaScript (node-redis)" }}
{{ else if eq $client "ioredis" }}
{{ $displayName = "JavaScript (ioredis)" }}
{{ end }}

{{ $tabs = $tabs | append (dict "title" $client "displayName" $displayName "language" $client "quickstartSlug" $quickstartSlug "content" $content "sourceUrl" (index $example "sourceUrl") "binderId" $binderId) }}
{{ end }}
{{ end }}

Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/tabs/wrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{{ if eq (index $tab "title") "redis-cli" }}
{{ $displayName = or (index $tab "displayName") $cliName }}
{{ else }}
{{ $displayName = index $tab "title" }}
{{ $displayName = or (index $tab "displayName") (index $tab "title") }}
{{ end }}
<option value="{{ $dataLang }}" data-index="{{ $i }}" {{ if eq $i 0 }}selected{{ end }}>
{{ $displayName }}
Expand Down
36 changes: 36 additions & 0 deletions local_examples/client-specific/ioredis/landing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// EXAMPLE: landing
// STEP_START connect
import { Redis } from 'ioredis';

const redis = new Redis();
// STEP_END

// STEP_START set_get_string
await redis.set('key', 'value');
const value = await redis.get('key');
console.log(value); // >>> value
// STEP_END

// STEP_START set_get_hash
await redis.hset('user-session:123', {
name: 'John',
surname: 'Smith',
company: 'Redis',
age: 29
});

const userSession = await redis.hgetall('user-session:123');
console.log(JSON.stringify(userSession, null, 2));
/* >>>
{
"surname": "Smith",
"name": "John",
"company": "Redis",
"age": "29"
}
*/
// STEP_END

// STEP_START close
redis.disconnect();
// STEP_END