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 @@ -35,6 +35,7 @@
'c#-async': '//',
'redisvl': '#',
'php': '//',
'ruby': '#',
'rust': '//',
'rust-sync': '//',
'rust-async': '//'
Expand Down
2 changes: 2 additions & 0 deletions build/local_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'.cs': 'c#',
'.java': 'java',
'.php': 'php',
'.rb': 'ruby',
'.rs': 'rust'
}

Expand All @@ -42,6 +43,7 @@
'c#': 'C#-Sync',
'java': 'Java-Sync', # Default to sync, could be overridden
'php': 'PHP',
'ruby': 'Ruby',
'redisvl': 'RedisVL',
'rust': 'Rust-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", "ioredis", "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", "Ruby", "Rust-Sync", "Rust-Async"]
searchService = "/convai/api/search-service"
ratingsService = "/docusight/api/rate/docs"

Expand Down Expand Up @@ -74,6 +74,7 @@ rdi_current_version = "1.16.1"
"C#-Async"={quickstartSlug="dotnet", langId="csharp", clientId="stackexchange-redis", clientName="StackExchange.Redis", mappingClientId="nredisstack_async"}
"RedisVL"={quickstartSlug="redis-vl", langId="python", clientId="redis-vl", clientName="RedisVL", mappingClientId="redis_vl"}
"PHP"={quickstartSlug="php", langId="php", clientId="predis", clientName="Predis", mappingClientId="php"}
"Ruby"={quickstartSlug="redis-rb", langId="ruby", clientId="redis-rb", clientName="redis-rb", mappingClientId="redis_rb"}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong quickstartSlug causes broken Ruby guide link

High Severity

The Ruby config entry uses quickstartSlug="redis-rb", but the actual guide page lives at content/develop/clients/ruby/, not content/develop/clients/redis-rb/. The tabbed examples template builds a link using "develop/clients/" + quickstartSlug, so this produces a link to develop/clients/redis-rb/ which is a 404. The slug needs to be "ruby" to match the directory name, consistent with how all other clients (e.g. "php"php/, "rust"rust/) map their slugs to their guide directories.

Fix in Cursor Fix in Web

"Rust-Sync"={quickstartSlug="rust", langId="rust", clientId="redis-rs", clientName="redis-rs", mappingClientId="redis_rs_sync"}
"Rust-Async"={quickstartSlug="rust", langId="rust", clientId="redis-rs", clientName="redis-rs", mappingClientId="redis_rs_async"}

Expand Down
6 changes: 3 additions & 3 deletions content/develop/clients/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ for eight main languages:
| [PHP](https://www.php.net/)| [`Predis`](https://github.com/predis/predis) | [`Predis` guide]({{< relref "/develop/clients/php" >}}) | Best effort [*](#best-effort) |
| [C](https://en.wikipedia.org/wiki/C_(programming_language)) | [`hiredis`](https://github.com/redis/hiredis) | [`hiredis` guide]({{< relref "/develop/clients/hiredis" >}}) | Yes |
| [Rust](https://www.rust-lang.org/) | [`redis-rs`](https://github.com/redis-rs/redis-rs) | [`redis-rs` guide]({{< relref "/develop/clients/rust" >}}) | Best effort [*](#best-effort) |
| [Ruby](https://www.ruby-lang.org/en/) | [`redis-rb`](https://github.com/redis/redis-rb) | [`redis-rb` guide]({{< relref "/develop/clients/ruby" >}}) | Yes |


{{< note >}}*<a name="best-effort"></a> Redis does not provide official support for third-party client libraries.
{{< note >}}*<a name="best-effort"></a>
Redis does not provide official support for third-party client libraries.
However, we contribute new features, offer guidance, and collaborate with the community
on a best-effort basis to help ensure these libraries remain reliable and up-to-date.
{{< /note >}}
Expand All @@ -61,7 +62,6 @@ Redis does not document directly:
| [C++](https://en.wikipedia.org/wiki/C%2B%2B) | Boost.Redis | https://github.com/boostorg/redis | https://www.boost.org/doc/libs/develop/libs/redis/doc/html/index.html |
| [Dart](https://dart.dev/) | redis_dart_link | https://github.com/toolsetlink/redis_dart_link | https://github.com/toolsetlink/redis_dart_link |
| [PHP](https://www.php.net/) | PhpRedis extension | https://github.com/phpredis/phpredis | https://github.com/phpredis/phpredis/blob/develop/README.md |
| [Ruby](https://www.ruby-lang.org/en/) | redis-rb | https://github.com/redis/redis-rb | https://rubydoc.info/gems/redis |


## Requirements
Expand Down
59 changes: 59 additions & 0 deletions content/develop/clients/ruby/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
categories:
- docs
- develop
- stack
- oss
- rs
- rc
- oss
- kubernetes
- clients
description: Connect your Ruby application to a Redis database
linkTitle: redis-rb (Ruby)
title: redis-rb guide (Ruby)
weight: 11
---

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

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

## Install

To install `redis-rb`, run the following command:

```bash
gem install redis
```

## Connect and test

Connect to localhost on port 6379:

{{< clients-example set="landing" step="connect" lang_filter="Ruby" description="Foundational: Connect to a Redis server and establish a client connection" difficulty="beginner" >}}
{{< /clients-example >}}

Store and retrieve a simple string.

{{< clients-example set="landing" step="set_get_string" lang_filter="Ruby" description="Foundational: Set and retrieve string values using SET and GET commands" difficulty="beginner" >}}
{{< /clients-example >}}

Store and retrieve a dict.

{{< clients-example set="landing" step="hash_operations" lang_filter="Ruby" description="Foundational: Store and retrieve hash data structures using HSET and HGETALL" difficulty="beginner" >}}
{{< /clients-example >}}

Close the connection when you're done.

{{< clients-example set="landing" step="close" lang_filter="Ruby" description="Foundational: Properly close a Redis client connection to release resources" difficulty="beginner" >}}
{{< /clients-example >}}

## More information

The
[GitHub repository](https://github.com/redis/redis-rb) for `redis-rb` has a
set of [examples](https://github.com/redis/redis-rb/tree/master/examples)
and further information about using redis-rb.
3 changes: 2 additions & 1 deletion data/components/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"redis_vl",
"redis_rs_sync",
"redis_rs_async",
"hi_redis"
"hi_redis",
"redis_rb"
],
"assets": [],
"website": {
Expand Down
16 changes: 16 additions & 0 deletions data/components/redis_rb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"id": "redis_rb",
"type": "client",
"name": "redis-rb",
"language": "Ruby",
"label": "Ruby",
"repository": {
"git_uri": "https://github.com/redis/redis-rb"
},
"examples": {
"git_uri": "https://github.com/redis/redis-rb",
"path": "examples",
"pattern": "*.rb"
}
}

29 changes: 29 additions & 0 deletions local_examples/client-specific/ruby/landing.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# EXAMPLE: landing
# STEP_START import
require 'redis'
# STEP_END

# STEP_START connect
r = Redis.new
# STEP_END

# STEP_START set_get_string
r.set 'foo', 'bar'
value = r.get('foo')
puts value # >>> bar
# STEP_END

# STEP_START hash_operations
r.hset 'user-session:123', 'name', 'John'
r.hset 'user-session:123', 'surname', 'Smith'
r.hset 'user-session:123', 'company', 'Redis'
r.hset 'user-session:123', 'age', 29

hash_value = r.hgetall('user-session:123')
puts hash_value
# >>> {"name"=>"John", "surname"=>"Smith", "company"=>"Redis", "age"=>"29"}
# STEP_END

# STEP_START close
r.close()
# STEP_END
Loading