Skip to content

Commit c6e2186

Browse files
Merge pull request #853 from redis/DOC-4543-split-client-pages
DOC-4543 split client pages into subpages
2 parents c7d2d08 + ae4a2d2 commit c6e2186

File tree

181 files changed

+2310
-1936
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+2310
-1936
lines changed

content/apis/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Redis comes with a wide range of commands that help you to develop real-time app
1818

1919
As a developer, you will likely use one of our supported client libraries for connecting and executing commands.
2020

21-
- [Connect with Redis clients introduction]({{< relref "/develop/connect/clients/" >}})
21+
- [Connect with Redis clients introduction]({{< relref "/develop/clients" >}})
2222

2323
### Programmability APIs
2424

content/commands/client-caching/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ title: CLIENT CACHING
4343
This command controls the tracking of the keys in the next command executed
4444
by the connection, when tracking is enabled in `OPTIN` or `OPTOUT` mode.
4545
Please check the
46-
[client side caching documentation]({{< relref "/develop/connect/clients/client-side-caching" >}}) for
46+
[client side caching documentation]({{< relref "/develop/clients/client-side-caching" >}}) for
4747
background information.
4848

4949
When tracking is enabled Redis, using the [`CLIENT TRACKING`]({{< relref "/commands/client-tracking" >}}) command, it is

content/commands/client-getredir/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ syntax_str: ''
3131
title: CLIENT GETREDIR
3232
---
3333
This command returns the client ID we are redirecting our
34-
[tracking]({{< relref "/develop/connect/clients/client-side-caching#tracking" >}}) notifications to. We set a client
34+
[tracking]({{< relref "/develop/clients/client-side-caching#tracking" >}}) notifications to. We set a client
3535
to redirect to when using [`CLIENT TRACKING`]({{< relref "/commands/client-tracking" >}}) to enable tracking. However in
3636
order to avoid forcing client libraries implementations to remember the
3737
ID notifications are redirected to, this command exists in order to improve

content/commands/client-tracking/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ syntax_str: "[REDIRECT\_client-id] [PREFIX\_prefix [PREFIX prefix ...]] [BCAST]
7575
title: CLIENT TRACKING
7676
---
7777
This command enables the tracking feature of the Redis server, that is used
78-
for [server assisted client side caching]({{< relref "/develop/connect/clients/client-side-caching#tracking" >}}).
78+
for [server assisted client side caching]({{< relref "/develop/clients/client-side-caching#tracking" >}}).
7979

8080
When tracking is enabled Redis remembers the keys that the connection
8181
requested, in order to send later invalidation messages when such keys are

content/commands/client-trackinginfo/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ syntax_fmt: CLIENT TRACKINGINFO
2929
syntax_str: ''
3030
title: CLIENT TRACKINGINFO
3131
---
32-
The command returns information about the current client connection's use of the [server assisted client side caching]({{< relref "/develop/connect/clients/client-side-caching" >}}) feature.
32+
The command returns information about the current client connection's use of the [server assisted client side caching]({{< relref "/develop/clients/client-side-caching" >}}) feature.
3333

3434
Here's the list of tracking information sections and their respective values:
3535

content/develop/connect/clients/_index.md renamed to content/develop/clients/_index.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
aliases: /develop/connect/clients
23
categories:
34
- docs
45
- develop
@@ -9,10 +10,11 @@ categories:
910
- oss
1011
- kubernetes
1112
- clients
13+
hideListLinks: true
1214
description: Connect your application to a Redis database and try an example
13-
linkTitle: Clients
14-
title: Connect with Redis clients
15-
weight: 45
15+
linkTitle: Client APIs
16+
title: Connect with Redis client API libraries
17+
weight: 30
1618
---
1719

1820
Use the Redis client libraries to connect to Redis servers from
@@ -21,17 +23,17 @@ for six main languages:
2123

2224
| Language | Client name | Docs | Supported |
2325
| :-- | :-- | :-- | :-- |
24-
| [Python](https://www.python.org/) | [`redis-py`](https://github.com/redis/redis-py) |[Redis Python library guide]({{< relref "/develop/connect/clients/python/redis-py" >}}) | Yes |
26+
| [Python](https://www.python.org/) | [`redis-py`](https://github.com/redis/redis-py) |[`redis-py` guide]({{< relref "/develop/clients/redis-py" >}}) | Yes |
2527
| [Python](https://www.python.org/) | [`RedisVL`](https://github.com/redis/redis-vl-python) |[RedisVL guide]({{< relref "/integrate/redisvl" >}}) | Yes
26-
| [C#/.NET](https://learn.microsoft.com/en-us/dotnet/csharp/) | [`NRedisStack`](https://github.com/redis/NRedisStack) |[C#/.NET guide]({{< relref "/develop/connect/clients/dotnet" >}}) | Yes |
27-
| [Node.js](https://nodejs.org/en) | [`node-redis`](https://github.com/redis/node-redis) | [Node.js guide]({{< relref "/develop/connect/clients/nodejs" >}}) | Yes |
28-
| [Java](https://www.java.com/en/) | [`Jedis`](https://github.com/redis/jedis) | [Jedis guide]({{< relref "/develop/connect/clients/java/jedis" >}}) | Yes |
29-
| [Java](https://www.java.com/en/) | [`Lettuce`](https://github.com/redis/lettuce) | [Lettuce guide]({{< relref "/develop/connect/clients/java/lettuce" >}}) | Yes |
30-
| [Go](https://go.dev/) | [`go-redis`](https://github.com/redis/go-redis) | [Go guide]({{< relref "/develop/connect/clients/go" >}}) | Yes |
31-
| [PHP](https://www.php.net/)| [`Predis`](https://github.com/predis/predis) | [PHP guide]({{< relref "/develop/connect/clients/php" >}}) | No |
28+
| [C#/.NET](https://learn.microsoft.com/en-us/dotnet/csharp/) | [`NRedisStack`](https://github.com/redis/NRedisStack) |[`NRedisStack` guide]({{< relref "/develop/clients/dotnet" >}}) | Yes |
29+
| [JavaScript](https://nodejs.org/en) | [`node-redis`](https://github.com/redis/node-redis) | [`node-redis` guide]({{< relref "/develop/clients/nodejs" >}}) | Yes |
30+
| [Java](https://www.java.com/en/) | [`Jedis`](https://github.com/redis/jedis) | [`Jedis` guide]({{< relref "/develop/clients/jedis" >}}) | Yes |
31+
| [Java](https://www.java.com/en/) | [`Lettuce`](https://github.com/redis/lettuce) | [`Lettuce` guide]({{< relref "/develop/clients/lettuce" >}}) | Yes |
32+
| [Go](https://go.dev/) | [`go-redis`](https://github.com/redis/go-redis) | [`go-redis` guide]({{< relref "/develop/clients/go" >}}) | Yes |
33+
| [PHP](https://www.php.net/)| [`Predis`](https://github.com/predis/predis) | [`Predis` guide]({{< relref "/develop/clients/php" >}}) | No |
3234

3335
We also provide several higher-level
34-
[object mapping (OM)]({{< relref "/develop/connect/clients/om-clients" >}})
36+
[object mapping (OM)]({{< relref "/develop/clients/om-clients" >}})
3537
libraries for [Python]({{< relref "/integrate/redisom-for-python" >}}),
3638
[C#/.NET]({{< relref "/integrate/redisom-for-net" >}}),
3739
[Node.js]({{< relref "/integrate/redisom-for-node-js" >}}), and
@@ -56,7 +58,5 @@ You will need access to a Redis server to use these libraries.
5658
You can experiment with a local installation of Redis Stack
5759
(see [Install Redis Stack]({{< relref "/operate/oss_and_stack/install/install-stack/" >}})) or with a free trial of [Redis Cloud]({{< relref "/operate/rc" >}}).
5860
To interact with a Redis server without writing code, use the
59-
[Redis CLI]({{< relref "/develop/connect/cli" >}}) and
60-
[Redis Insight]({{< relref "/develop/connect/insight" >}}) tools.
61-
62-
## Client library guides
61+
[Redis CLI]({{< relref "/develop/tools/cli" >}}) and
62+
[Redis Insight]({{< relref "/develop/tools/insight" >}}) tools.

content/develop/connect/clients/client-side-caching.md renamed to content/develop/clients/client-side-caching.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
aliases: /develop/connect/clients/client-side-caching
23
categories:
34
- docs
45
- develop
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
aliases: /develop/connect/clients/dotnet
3+
categories:
4+
- docs
5+
- develop
6+
- stack
7+
- oss
8+
- rs
9+
- rc
10+
- oss
11+
- kubernetes
12+
- clients
13+
description: Connect your .NET application to a Redis database
14+
linkTitle: NRedisStack (C#/.NET)
15+
title: NRedisStack guide (C#/.NET)
16+
weight: 3
17+
---
18+
19+
[NRedisStack](https://github.com/redis/NRedisStack) is the .NET client for Redis.
20+
The sections below explain how to install `NRedisStack` and connect your application
21+
to a Redis database.
22+
23+
`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.
24+
25+
You can also access Redis with an object-mapping client interface. See
26+
[Redis OM for .NET]({{< relref "/integrate/redisom-for-net" >}})
27+
for more information.
28+
29+
## Install
30+
31+
Using the `dotnet` CLI, run:
32+
33+
```bash
34+
dotnet add package NRedisStack
35+
```
36+
37+
## Connect and test
38+
39+
Connect to localhost on port 6379.
40+
41+
```csharp
42+
using NRedisStack;
43+
using NRedisStack.RedisStackCommands;
44+
using StackExchange.Redis;
45+
//...
46+
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
47+
IDatabase db = redis.GetDatabase();
48+
```
49+
50+
You can test the connection by storing and retrieving a simple string.
51+
52+
```csharp
53+
db.StringSet("foo", "bar");
54+
Console.WriteLine(db.StringGet("foo")); // prints bar
55+
```
56+
57+
Store and retrieve a HashMap.
58+
59+
```csharp
60+
var hash = new HashEntry[] {
61+
new HashEntry("name", "John"),
62+
new HashEntry("surname", "Smith"),
63+
new HashEntry("company", "Redis"),
64+
new HashEntry("age", "29"),
65+
};
66+
db.HashSet("user-session:123", hash);
67+
68+
var hashFields = db.HashGetAll("user-session:123");
69+
Console.WriteLine(String.Join("; ", hashFields));
70+
// Prints:
71+
// name: John; surname: Smith; company: Redis; age: 29
72+
```
73+
## Redis Stack modules
74+
75+
To access Redis Stack capabilities, use the appropriate interface like this:
76+
77+
```
78+
IBloomCommands bf = db.BF();
79+
ICuckooCommands cf = db.CF();
80+
ICmsCommands cms = db.CMS();
81+
IGraphCommands graph = db.GRAPH();
82+
ITopKCommands topk = db.TOPK();
83+
ITdigestCommands tdigest = db.TDIGEST();
84+
ISearchCommands ft = db.FT();
85+
IJsonCommands json = db.JSON();
86+
ITimeSeriesCommands ts = db.TS();
87+
```
88+
89+
## More information
90+
91+
See the other pages in this section for more information and examples.
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
---
2+
categories:
3+
- docs
4+
- develop
5+
- stack
6+
- oss
7+
- rs
8+
- rc
9+
- oss
10+
- kubernetes
11+
- clients
12+
description: Connect your .NET application to a Redis database
13+
linkTitle: Connect
14+
title: Connect to the server
15+
weight: 2
16+
---
17+
18+
## Basic connection
19+
20+
You can connect to the server simply by passing a string of the
21+
form "hostname:port" to the `Connect()` method (for example,
22+
"localhost:6379"). However, you can also connect using a
23+
`ConfigurationOptions` parameter. Use this to specify a
24+
username, password, and many other options:
25+
26+
```csharp
27+
using NRedisStack;
28+
using NRedisStack.RedisStackCommands;
29+
using StackExchange.Redis;
30+
31+
ConfigurationOptions conf = new ConfigurationOptions {
32+
EndPoints = { "localhost:6379" },
33+
User = "yourUsername",
34+
Password = "yourPassword"
35+
};
36+
37+
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(conf);
38+
IDatabase db = redis.GetDatabase();
39+
40+
db.StringSet("foo", "bar");
41+
Console.WriteLine(db.StringGet("foo")); // prints bar
42+
```
43+
44+
## Connect to a Redis cluster
45+
46+
The basic connection will use the
47+
[Cluster API]({{< relref "/operate/rs/clusters/optimize/oss-cluster-api" >}})
48+
if it is available without any special configuration. However, if you know
49+
the addresses and ports of several cluster nodes, you can specify them all
50+
during connection in the `Endpoints` parameter:
51+
52+
```csharp
53+
ConfigurationOptions options = new ConfigurationOptions
54+
{
55+
//list of available nodes of the cluster along with the endpoint port.
56+
EndPoints = {
57+
{ "localhost", 16379 },
58+
{ "localhost", 16380 },
59+
// ...
60+
},
61+
};
62+
63+
ConnectionMultiplexer cluster = ConnectionMultiplexer.Connect(options);
64+
IDatabase db = cluster.GetDatabase();
65+
66+
db.StringSet("foo", "bar");
67+
Console.WriteLine(db.StringGet("foo")); // prints bar
68+
```
69+
70+
## Connect to your production Redis with TLS
71+
72+
When you deploy your application, use TLS and follow the [Redis security]({{< relref "/operate/oss_and_stack/management/security/" >}}) guidelines.
73+
74+
Before connecting your application to the TLS-enabled Redis server, ensure that your certificates and private keys are in the correct format.
75+
76+
To convert user certificate and private key from the PEM format to `pfx`, use this command:
77+
78+
```bash
79+
openssl pkcs12 -inkey redis_user_private.key -in redis_user.crt -export -out redis.pfx
80+
```
81+
82+
Enter password to protect your `pfx` file.
83+
84+
Establish a secure connection with your Redis database using this snippet.
85+
86+
```csharp
87+
ConfigurationOptions options = new ConfigurationOptions
88+
{
89+
EndPoints = { { "my-redis.cloud.redislabs.com", 6379 } },
90+
User = "default", // use your Redis user. More info https://redis.io/docs/latest/operate/oss_and_stack/management/security/acl/
91+
Password = "secret", // use your Redis password
92+
Ssl = true,
93+
SslProtocols = System.Security.Authentication.SslProtocols.Tls12
94+
};
95+
96+
options.CertificateSelection += delegate
97+
{
98+
return new X509Certificate2("redis.pfx", "secret"); // use the password you specified for pfx file
99+
};
100+
options.CertificateValidation += ValidateServerCertificate;
101+
102+
bool ValidateServerCertificate(
103+
object sender,
104+
X509Certificate? certificate,
105+
X509Chain? chain,
106+
SslPolicyErrors sslPolicyErrors)
107+
{
108+
if (certificate == null) {
109+
return false;
110+
}
111+
112+
var ca = new X509Certificate2("redis_ca.pem");
113+
bool verdict = (certificate.Issuer == ca.Subject);
114+
if (verdict) {
115+
return true;
116+
}
117+
Console.WriteLine("Certificate error: {0}", sslPolicyErrors);
118+
return false;
119+
}
120+
121+
ConnectionMultiplexer muxer = ConnectionMultiplexer.Connect(options);
122+
123+
//Creation of the connection to the DB
124+
IDatabase conn = muxer.GetDatabase();
125+
126+
//send SET command
127+
conn.StringSet("foo", "bar");
128+
129+
//send GET command and print the value
130+
Console.WriteLine(conn.StringGet("foo"));
131+
```
132+
133+
## Multiplexing
134+
135+
Although example code typically works with a single connection,
136+
real-world code often uses multiple connections at the same time.
137+
Opening and closing connections repeatedly is inefficient, so it is best
138+
to manage open connections carefully to avoid this.
139+
140+
Several other
141+
Redis client libraries use *connection pools* to reuse a set of open
142+
connections efficiently. NRedisStack uses a different approach called
143+
*multiplexing*, which sends all client commands and responses over a
144+
single connection. NRedisStack manages multiplexing for you automatically.
145+
This gives high performance without requiring any extra coding.
146+
See
147+
[Connection pools and multiplexing]({{< relref "/develop/clients/pools-and-muxing" >}})
148+
for more information.

0 commit comments

Comments
 (0)