-
Notifications
You must be signed in to change notification settings - Fork 270
DOC-4543 split client pages into subpages #853
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 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6d2397b
DOC-4543 split C# client page into subpages
andy-stark-redis 16918e9
DOC-4543 split Go client page and removed Connect folder level
andy-stark-redis e72ad00
DOC-4543 renaming and moving Python/Java libs up a level
andy-stark-redis bd90eda
DOC-4543 split redis-py and Jedis pages
andy-stark-redis 29750f4
DOC-4543 started splitting Lettuce page
andy-stark-redis e321bbe
DOC-4543 more Lettuce stuff:
andy-stark-redis e1a2693
DOC-4543 finished Lettuce stuff
andy-stark-redis 747f50a
DOC-4543 split node-redis client page
andy-stark-redis 2cc8c0b
DOC-4543 split PHP client page
andy-stark-redis 0d555ea
DOC-4543 added aliases to client pages
andy-stark-redis 27993f2
DOC-4543 fix links to client section pages
andy-stark-redis 979a003
DOC-4543 fixed links to CLI page
andy-stark-redis 96063b6
DOC-4543 fixed more broken links
andy-stark-redis 64437a0
DOC-4543 fixed remaining broken links
andy-stark-redis 9e5fb11
DOC-4543 added aliases
andy-stark-redis daf2053
DOC-4543 small fixes
andy-stark-redis ae4a2d2
Update content/develop/clients/_index.md
andy-stark-redis 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
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
1 change: 1 addition & 0 deletions
1
...op/connect/clients/client-side-caching.md → ...nt/develop/clients/client-side-caching.md
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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| --- | ||
| aliases: /develop/connect/clients/client-side-caching | ||
| categories: | ||
| - docs | ||
| - develop | ||
|
|
||
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,91 @@ | ||
| --- | ||
| aliases: /develop/connect/clients/dotnet | ||
| categories: | ||
| - docs | ||
| - develop | ||
| - stack | ||
| - oss | ||
| - rs | ||
| - rc | ||
| - oss | ||
| - kubernetes | ||
| - clients | ||
| description: Connect your .NET application to a Redis database | ||
| linkTitle: NRedisStack (C#/.NET) | ||
| title: NRedisStack guide (C#/.NET) | ||
| weight: 3 | ||
| --- | ||
|
|
||
| [NRedisStack](https://github.com/redis/NRedisStack) is the .NET client for Redis. | ||
| The sections below explain how to install `NRedisStack` and connect your application | ||
| to a Redis database. | ||
|
|
||
| `NRedisStack` requires a running Redis or [Redis Stack]({{< relref "/operate/oss_and_stack/install/install-stack/" >}}) server. See [Getting started]({{< relref "/operate/oss_and_stack/install/" >}}) for Redis installation instructions. | ||
|
|
||
| You can also access Redis with an object-mapping client interface. See | ||
| [Redis OM for .NET]({{< relref "/integrate/redisom-for-net" >}}) | ||
| for more information. | ||
|
|
||
| ## Install | ||
|
|
||
| Using the `dotnet` CLI, run: | ||
|
|
||
| ```bash | ||
| dotnet add package NRedisStack | ||
| ``` | ||
|
|
||
| ## Connect and test | ||
|
|
||
| Connect to localhost on port 6379. | ||
|
|
||
| ```csharp | ||
| using NRedisStack; | ||
| using NRedisStack.RedisStackCommands; | ||
| using StackExchange.Redis; | ||
| //... | ||
| ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost"); | ||
| IDatabase db = redis.GetDatabase(); | ||
| ``` | ||
|
|
||
| You can test the connection by storing and retrieving a simple string. | ||
|
|
||
| ```csharp | ||
| db.StringSet("foo", "bar"); | ||
| Console.WriteLine(db.StringGet("foo")); // prints bar | ||
| ``` | ||
|
|
||
| Store and retrieve a HashMap. | ||
|
|
||
| ```csharp | ||
| var hash = new HashEntry[] { | ||
| new HashEntry("name", "John"), | ||
| new HashEntry("surname", "Smith"), | ||
| new HashEntry("company", "Redis"), | ||
| new HashEntry("age", "29"), | ||
| }; | ||
| db.HashSet("user-session:123", hash); | ||
|
|
||
| var hashFields = db.HashGetAll("user-session:123"); | ||
| Console.WriteLine(String.Join("; ", hashFields)); | ||
| // Prints: | ||
| // name: John; surname: Smith; company: Redis; age: 29 | ||
| ``` | ||
| ## Redis Stack modules | ||
|
|
||
| To access Redis Stack capabilities, use the appropriate interface like this: | ||
|
|
||
| ``` | ||
| IBloomCommands bf = db.BF(); | ||
| ICuckooCommands cf = db.CF(); | ||
| ICmsCommands cms = db.CMS(); | ||
| IGraphCommands graph = db.GRAPH(); | ||
| ITopKCommands topk = db.TOPK(); | ||
| ITdigestCommands tdigest = db.TDIGEST(); | ||
| ISearchCommands ft = db.FT(); | ||
| IJsonCommands json = db.JSON(); | ||
| ITimeSeriesCommands ts = db.TS(); | ||
| ``` | ||
|
|
||
| ## More information | ||
|
|
||
| See the other pages in this section for more information and examples. |
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,148 @@ | ||
| --- | ||
| categories: | ||
| - docs | ||
| - develop | ||
| - stack | ||
| - oss | ||
| - rs | ||
| - rc | ||
| - oss | ||
| - kubernetes | ||
| - clients | ||
| description: Connect your .NET application to a Redis database | ||
| linkTitle: Connect | ||
| title: Connect to the server | ||
| weight: 2 | ||
| --- | ||
|
|
||
| ## Basic connection | ||
|
|
||
| You can connect to the server simply by passing a string of the | ||
| form "hostname:port" to the `Connect()` method (for example, | ||
| "localhost:6379"). However, you can also connect using a | ||
| `ConfigurationOptions` parameter. Use this to specify a | ||
| username, password, and many other options: | ||
|
|
||
| ```csharp | ||
| using NRedisStack; | ||
| using NRedisStack.RedisStackCommands; | ||
| using StackExchange.Redis; | ||
|
|
||
| ConfigurationOptions conf = new ConfigurationOptions { | ||
| EndPoints = { "localhost:6379" }, | ||
| User = "yourUsername", | ||
| Password = "yourPassword" | ||
| }; | ||
|
|
||
| ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(conf); | ||
| IDatabase db = redis.GetDatabase(); | ||
|
|
||
| db.StringSet("foo", "bar"); | ||
| Console.WriteLine(db.StringGet("foo")); // prints bar | ||
| ``` | ||
|
|
||
| ## Connect to a Redis cluster | ||
|
|
||
| The basic connection will use the | ||
| [Cluster API]({{< relref "/operate/rs/clusters/optimize/oss-cluster-api" >}}) | ||
| if it is available without any special configuration. However, if you know | ||
| the addresses and ports of several cluster nodes, you can specify them all | ||
| during connection in the `Endpoints` parameter: | ||
|
|
||
| ```csharp | ||
| ConfigurationOptions options = new ConfigurationOptions | ||
| { | ||
| //list of available nodes of the cluster along with the endpoint port. | ||
| EndPoints = { | ||
| { "localhost", 16379 }, | ||
| { "localhost", 16380 }, | ||
| // ... | ||
| }, | ||
| }; | ||
|
|
||
| ConnectionMultiplexer cluster = ConnectionMultiplexer.Connect(options); | ||
| IDatabase db = cluster.GetDatabase(); | ||
|
|
||
| db.StringSet("foo", "bar"); | ||
| Console.WriteLine(db.StringGet("foo")); // prints bar | ||
| ``` | ||
|
|
||
| ## Connect to your production Redis with TLS | ||
|
|
||
| When you deploy your application, use TLS and follow the [Redis security]({{< relref "/operate/oss_and_stack/management/security/" >}}) guidelines. | ||
|
|
||
| Before connecting your application to the TLS-enabled Redis server, ensure that your certificates and private keys are in the correct format. | ||
|
|
||
| To convert user certificate and private key from the PEM format to `pfx`, use this command: | ||
|
|
||
| ```bash | ||
| openssl pkcs12 -inkey redis_user_private.key -in redis_user.crt -export -out redis.pfx | ||
| ``` | ||
|
|
||
| Enter password to protect your `pfx` file. | ||
|
|
||
| Establish a secure connection with your Redis database using this snippet. | ||
|
|
||
| ```csharp | ||
| ConfigurationOptions options = new ConfigurationOptions | ||
| { | ||
| EndPoints = { { "my-redis.cloud.redislabs.com", 6379 } }, | ||
| User = "default", // use your Redis user. More info https://redis.io/docs/latest/operate/oss_and_stack/management/security/acl/ | ||
| Password = "secret", // use your Redis password | ||
| Ssl = true, | ||
| SslProtocols = System.Security.Authentication.SslProtocols.Tls12 | ||
| }; | ||
|
|
||
| options.CertificateSelection += delegate | ||
| { | ||
| return new X509Certificate2("redis.pfx", "secret"); // use the password you specified for pfx file | ||
| }; | ||
| options.CertificateValidation += ValidateServerCertificate; | ||
|
|
||
| bool ValidateServerCertificate( | ||
| object sender, | ||
| X509Certificate? certificate, | ||
| X509Chain? chain, | ||
| SslPolicyErrors sslPolicyErrors) | ||
| { | ||
| if (certificate == null) { | ||
| return false; | ||
| } | ||
|
|
||
| var ca = new X509Certificate2("redis_ca.pem"); | ||
| bool verdict = (certificate.Issuer == ca.Subject); | ||
| if (verdict) { | ||
| return true; | ||
| } | ||
| Console.WriteLine("Certificate error: {0}", sslPolicyErrors); | ||
| return false; | ||
| } | ||
|
|
||
| ConnectionMultiplexer muxer = ConnectionMultiplexer.Connect(options); | ||
|
|
||
| //Creation of the connection to the DB | ||
| IDatabase conn = muxer.GetDatabase(); | ||
|
|
||
| //send SET command | ||
| conn.StringSet("foo", "bar"); | ||
|
|
||
| //send GET command and print the value | ||
| Console.WriteLine(conn.StringGet("foo")); | ||
| ``` | ||
|
|
||
| ## Multiplexing | ||
|
|
||
| Although example code typically works with a single connection, | ||
| real-world code often uses multiple connections at the same time. | ||
| Opening and closing connections repeatedly is inefficient, so it is best | ||
| to manage open connections carefully to avoid this. | ||
|
|
||
| Several other | ||
| Redis client libraries use *connection pools* to reuse a set of open | ||
| connections efficiently. NRedisStack uses a different approach called | ||
| *multiplexing*, which sends all client commands and responses over a | ||
| single connection. NRedisStack manages multiplexing for you automatically. | ||
| This gives high performance without requiring any extra coding. | ||
| See | ||
| [Connection pools and multiplexing]({{< relref "/develop/clients/pools-and-muxing" >}}) | ||
| for more information. |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.