-
Notifications
You must be signed in to change notification settings - Fork 318
DOC-6353 added basic Ruby support #2874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 atcontent/develop/clients/ruby/, notcontent/develop/clients/redis-rb/. The tabbed examples template builds a link using"develop/clients/" + quickstartSlug, so this produces a link todevelop/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.