diff --git a/build/components/example.py b/build/components/example.py index 3e298714d0..cf7de18a2f 100644 --- a/build/components/example.py +++ b/build/components/example.py @@ -23,6 +23,7 @@ PREFIXES = { 'python': '#', 'node.js': '//', + 'ioredis': '//', 'java': '//', 'java-sync': '//', 'java-async': '//', diff --git a/build/local_examples.py b/build/local_examples.py index 470fec6315..b40b65cdaf 100644 --- a/build/local_examples.py +++ b/build/local_examples.py @@ -59,6 +59,10 @@ 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 @@ -66,6 +70,9 @@ def get_client_name_from_language_and_path(language: str, path: str) -> str: 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' diff --git a/config.toml b/config.toml index 2f04aa7ace..063a3fb1b4 100644 --- a/config.toml +++ b/config.toml @@ -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" @@ -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"} diff --git a/content/develop/clients/_index.md b/content/develop/clients/_index.md index 142a4de449..bd1b986dc0 100644 --- a/content/develop/clients/_index.md +++ b/content/develop/clients/_index.md @@ -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 | diff --git a/content/develop/clients/ioredis/_index.md b/content/develop/clients/ioredis/_index.md new file mode 100644 index 0000000000..1be2941d56 --- /dev/null +++ b/content/develop/clients/ioredis/_index.md @@ -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). diff --git a/content/develop/clients/nodejs/_index.md b/content/develop/clients/nodejs/_index.md index a4c0281bdd..d23c8a786a 100644 --- a/content/develop/clients/nodejs/_index.md +++ b/content/develop/clients/nodejs/_index.md @@ -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 diff --git a/content/develop/clients/nodejs/migration.md b/content/develop/clients/nodejs/migration.md index 3abfb79055..4406796b62 100644 --- a/content/develop/clients/nodejs/migration.md +++ b/content/develop/clients/nodejs/migration.md @@ -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 diff --git a/data/components/index.json b/data/components/index.json index 6a7b4f4caa..3f33b63872 100644 --- a/data/components/index.json +++ b/data/components/index.json @@ -11,6 +11,7 @@ "nredisstack_async", "go_redis", "node_redis", + "ioredis", "php", "redis_py", "jedis", diff --git a/data/components/ioredis.json b/data/components/ioredis.json new file mode 100644 index 0000000000..1a38a32a6d --- /dev/null +++ b/data/components/ioredis.json @@ -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" + } +} + diff --git a/layouts/partials/tabbed-clients-example.html b/layouts/partials/tabbed-clients-example.html index 84a218a3f3..1e73d3cb8d 100644 --- a/layouts/partials/tabbed-clients-example.html +++ b/layouts/partials/tabbed-clients-example.html @@ -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 }} diff --git a/layouts/partials/tabs/wrapper.html b/layouts/partials/tabs/wrapper.html index 9426a9628d..2c56c544dc 100644 --- a/layouts/partials/tabs/wrapper.html +++ b/layouts/partials/tabs/wrapper.html @@ -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 }}