Skip to content

Commit 9236bb7

Browse files
committed
Merge branch 'main' into release-rs-fuya-fuya
2 parents 67f7d7b + cd48689 commit 9236bb7

File tree

88 files changed

+1073
-224
lines changed

Some content is hidden

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

88 files changed

+1073
-224
lines changed

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/use/client-side-caching" >}}) for
46+
[client side caching documentation]({{< relref "/develop/connect/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/use/client-side-caching" >}}) notifications to. We set a client
34+
[tracking]({{< relref "/develop/connect/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: 2 additions & 2 deletions
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/use/client-side-caching" >}}).
78+
for [server assisted client side caching]({{< relref "/develop/connect/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
@@ -85,7 +85,7 @@ when the RESP3 protocol is used) or redirected in a different connection
8585
available where clients participating in this protocol receive every
8686
notification just subscribing to given key prefixes, regardless of the
8787
keys that they requested. Given the complexity of the argument please
88-
refer to [the main client side caching documentation]({{< relref "/develop/use/client-side-caching" >}}) for the details. This manual page is only a reference for the options of this subcommand.
88+
refer to [the main client side caching documentation]({{< relref "/develop/reference/client-side-caching" >}}) for the details. This manual page is only a reference for the options of this subcommand.
8989

9090
In order to enable tracking, use:
9191

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/use/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/connect/clients/client-side-caching" >}}) feature.
3333

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

content/commands/info/index.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,3 +515,24 @@ It won't be included when `INFO` or `INFO ALL` are called, and it is returned on
515515
**A note about the word slave used in this man page**: Starting with Redis 5, if not for backward compatibility, the Redis project no longer uses the word slave. Unfortunately in this command the word slave is part of the protocol, so we'll be able to remove such occurrences only when this API will be naturally deprecated.
516516

517517
**Modules generated sections**: Starting with Redis 6, modules can inject their information into the `INFO` command. These are excluded by default even when the `all` argument is provided (it will include a list of loaded modules but not their generated info fields). To get these you must use either the `modules` argument or `everything`.
518+
519+
## Redis Software and Redis Cloud compatibility
520+
521+
| Redis<br />Enterprise | Redis<br />Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> |
522+
|:----------------------|:-----------------|:------|
523+
| <span title="Supported">&#x2705; Standard</span><br /><span title="Supported"><nobr>&#x2705; Active-Active</nobr></span> | <span title="Supported">&#x2705; Standard</span><br /><span title="Supported"><nobr>&#x2705; Active-Active</nobr></span> | In Redis Enterprise, `INFO` returns a different set of fields than Redis Community Edition.<br />Not supported for [scripts]({{<relref "/develop/interact/programmability">}}). |
524+
525+
Note: key memory usage is different on Redis Software or Redis Cloud active-active databases than on non-active-active databases. This is because memory usage includes some amount of CRDB overhead.
526+
527+
Additionally, for JSON keys, Redis implements a “shared string” mechanism to save memory when the same JSON field names or field values of type string are used more than once (either inter-key or intra-key).
528+
In such cases, instead of storing the field names or values many times, Redis stores them only once. This mechanism is not in place for active-active databases.
529+
530+
On non-active-active databases, `INFO` (Memory > used_memory) reports that the shared memory is counted, but only once for all keys. On active-active databases, there is no shared memory, so if strings are repeated, they are stored multiple times.
531+
532+
**Example**
533+
534+
Suppose you have ten JSON keys, and each key has 5KB of unique content and 5KB of shared content.
535+
536+
For non-active-active databases, `INFO` (used_memory) would report (10 keys * 5KB) + 5KB ~= 55KB. The last term, "+ 5KB", is the size of the shared content.
537+
538+
For active-active databases, `INFO` (used_memory) would report 10 keys * 20KB ~= 200KB. This number includes some amount of CRDB overhead per JSON key.

content/commands/memory-usage/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,11 @@ OK
8787
> MEMORY USAGE foo3
8888
(integer) 160
8989
```
90+
91+
## Redis Software and Redis Cloud compatibility
92+
93+
| Redis<br />Enterprise | Redis<br />Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> |
94+
|:----------------------|:-----------------|:------|
95+
|<span title="Supported">&#x2705; Standard</span><br /><span title="Supported"><nobr>&#x2705; Active-Active</nobr></span> | <span title="Supported">&#x2705; Standard</span><br /><span title="Supported"><nobr>&#x2705; Active-Active</nobr></span> | Not supported for [scripts]({{<relref "/develop/interact/programmability">}}) in Redis versions earlier than 7. |
96+
97+
Note: key memory usage is different on Redis Software or Redis Cloud active-active databases than on non-active-active databases. This is because memory usage includes some amount of CRDB overhead.

content/develop/connect/clients/_index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ Redis does not support directly:
3939
| Language | Client name | Github | Docs |
4040
| :-- | :-- | :-- | :-- |
4141
| C | hiredis | https://github.com/redis/hiredis | https://github.com/redis/hiredis |
42-
| [PHP](https://www.php.net/) | predis | https://github.com/predis/predis | https://github.com/predis/predis/wiki |
42+
| [PHP](https://www.php.net/) | redis extension | https://github.com/phpredis/phpredis | https://github.com/phpredis/phpredis/blob/develop/README.md |
43+
| [PHP](https://www.php.net/) | predis library | https://github.com/predis/predis | https://github.com/predis/predis/wiki |
4344
| [Ruby](https://www.ruby-lang.org/en/) | redis-rb | https://github.com/redis/redis-rb | https://rubydoc.info/gems/redis |
4445
| [Rust](https://www.rust-lang.org/) | redis-rs | https://github.com/redis-rs/redis-rs | https://docs.rs/redis/latest/redis/ |
4546

@@ -52,4 +53,4 @@ To interact with a Redis server without writing code, use the
5253
[Redis CLI]({{< relref "/develop/connect/cli" >}}) and
5354
[Redis Insight]({{< relref "/develop/connect/insight" >}}) tools.
5455

55-
## Client library guides
56+
## Client library guides

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ client-side caching works well in the very common use case where a small subset
4343
is accessed much more frequently than the rest of the data (according
4444
to the [Pareto principle](https://en.wikipedia.org/wiki/Pareto_principle)).
4545

46-
## Updating the cache when the data changes
46+
## Updating the cache when the data changes {#tracking}
4747

4848
All caching systems must implement a scheme to update data in the cache
4949
when the corresponding data changes in the main database. Redis uses an
@@ -86,7 +86,7 @@ will use cached data, except for the following:
8686
[`HSCAN`]({{< relref "/commands/hscan" >}}),
8787
and [`ZRANDMEMBER`]({{< relref "/commands/zrandmember" >}}). By design, these commands
8888
give different results each time they are called.
89-
- Search and query commands (with the `FT.*` prefix), such as
89+
- Redis Query Engine commands (with the `FT.*` prefix), such as
9090
[`FT.SEARCH`]({{< baseurl >}}/commands/ft.search).
9191

9292
You can use the [`MONITOR`]({{< relref "/commands/monitor" >}}) command to

content/develop/connect/clients/dotnet.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dotnet add package NRedisStack
3737

3838
Connect to localhost on port 6379.
3939

40-
```
40+
```csharp
4141
using NRedisStack;
4242
using NRedisStack.RedisStackCommands;
4343
using StackExchange.Redis;
@@ -70,7 +70,7 @@ Console.WriteLine(String.Join("; ", hashFields));
7070
// name: John; surname: Smith; company: Redis; age: 29
7171
```
7272

73-
To access Redis Stack capabilities, you should use appropriate interface like this:
73+
To access Redis Stack capabilities, use the appropriate interface like this:
7474

7575
```
7676
IBloomCommands bf = db.BF();
@@ -84,7 +84,7 @@ IJsonCommands json = db.JSON();
8484
ITimeSeriesCommands ts = db.TS();
8585
```
8686

87-
### Connect to a Redis cluster
87+
## Connect to a Redis cluster
8888

8989
To connect to a Redis cluster, you just need to specify one or all cluster endpoints in the client configuration:
9090

@@ -106,7 +106,7 @@ db.StringSet("foo", "bar");
106106
Console.WriteLine(db.StringGet("foo")); // prints bar
107107
```
108108

109-
### Connect to your production Redis with TLS
109+
## Connect to your production Redis with TLS
110110

111111
When you deploy your application, use TLS and follow the [Redis security]({{< relref "/operate/oss_and_stack/management/security/" >}}) guidelines.
112112

@@ -169,6 +169,23 @@ conn.StringSet("foo", "bar");
169169
Console.WriteLine(conn.StringGet("foo"));
170170
```
171171

172+
## Multiplexing
173+
174+
Although example code typically works with a single connection,
175+
real-world code often uses multiple connections at the same time.
176+
Opening and closing connections repeatedly is inefficient, so it is best
177+
to manage open connections carefully to avoid this.
178+
179+
Several other
180+
Redis client libraries use *connection pools* to reuse a set of open
181+
connections efficiently. NRedisStack uses a different approach called
182+
*multiplexing*, which sends all client commands and responses over a
183+
single connection. NRedisStack manages multiplexing for you automatically.
184+
This gives high performance without requiring any extra coding.
185+
See
186+
[Connection pools and multiplexing]({{< relref "/develop/connect/clients/pools-and-muxing" >}})
187+
for more information.
188+
172189
## Example: Indexing and querying JSON documents
173190

174191
This example shows how to convert Redis search results to JSON format using `NRedisStack`.

content/develop/connect/clients/java/jedis.md

Lines changed: 72 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -56,46 +56,36 @@ To include `Jedis` as a dependency in your application, edit the dependency file
5656

5757
## Connect
5858

59-
For many applications, it's best to use a connection pool. You can instantiate and use a `Jedis` connection pool like so:
59+
The following code opens a basic connection to a local Redis server:
6060

6161
```java
6262
package org.example;
63-
import redis.clients.jedis.Jedis;
64-
import redis.clients.jedis.JedisPool;
63+
import redis.clients.jedis.UnifiedJedis;
6564

6665
public class Main {
6766
public static void main(String[] args) {
68-
JedisPool pool = new JedisPool("localhost", 6379);
67+
UnifiedJedis jedis = new UnifiedJedis("redis://localhost:6379");
6968

70-
try (Jedis jedis = pool.getResource()) {
71-
// Store & Retrieve a simple string
72-
jedis.set("foo", "bar");
73-
System.out.println(jedis.get("foo")); // prints bar
74-
75-
// Store & Retrieve a HashMap
76-
Map<String, String> hash = new HashMap<>();;
77-
hash.put("name", "John");
78-
hash.put("surname", "Smith");
79-
hash.put("company", "Redis");
80-
hash.put("age", "29");
81-
jedis.hset("user-session:123", hash);
82-
System.out.println(jedis.hgetAll("user-session:123"));
83-
// Prints: {name=John, surname=Smith, company=Redis, age=29}
84-
}
69+
// Code that interacts with Redis...
70+
71+
jedis.close();
8572
}
8673
}
8774
```
8875

89-
Because adding a `try-with-resources` block for each command can be cumbersome, consider using `JedisPooled` as an easier way to pool connections.
76+
After you have connected, you can check the connection by storing and
77+
retrieving a simple string value:
9078

9179
```java
92-
import redis.clients.jedis.JedisPooled;
80+
...
9381

94-
//...
82+
String res1 = jedis.set("bike:1", "Deimos");
83+
System.out.println(res1); // OK
9584

96-
JedisPooled jedis = new JedisPooled("localhost", 6379);
97-
jedis.set("foo", "bar");
98-
System.out.println(jedis.get("foo")); // prints "bar"
85+
String res2 = jedis.get("bike:1");
86+
System.out.println(res2); // Deimos
87+
88+
...
9989
```
10090

10191
### Connect to a Redis cluster
@@ -313,15 +303,61 @@ The client will also flush the cache automatically
313303
if any connection (including one from a connection pool)
314304
is disconnected.
315305

316-
## Production usage
306+
## Connect with a connection pool
317307

318-
The following sections explain how to handle situations that may occur
319-
in your production environment.
308+
For production usage, you should use a connection pool to manage
309+
connections rather than opening and closing connections individually.
310+
A connection pool maintains several open connections and reuses them
311+
efficiently. When you open a connection from a pool, the pool allocates
312+
one of its open connections. When you subsequently close the same connection,
313+
it is not actually closed but simply returned to the pool for reuse.
314+
This avoids the overhead of repeated connecting and disconnecting.
315+
See
316+
[Connection pools and multiplexing]({{< relref "/develop/connect/clients/pools-and-muxing" >}})
317+
for more information.
318+
319+
Use the following code to connect with a connection pool:
320+
321+
```java
322+
package org.example;
323+
import redis.clients.jedis.Jedis;
324+
import redis.clients.jedis.JedisPool;
325+
326+
public class Main {
327+
public static void main(String[] args) {
328+
JedisPool pool = new JedisPool("localhost", 6379);
329+
330+
try (Jedis jedis = pool.getResource()) {
331+
// Store & Retrieve a simple string
332+
jedis.set("foo", "bar");
333+
System.out.println(jedis.get("foo")); // prints bar
334+
335+
// Store & Retrieve a HashMap
336+
Map<String, String> hash = new HashMap<>();;
337+
hash.put("name", "John");
338+
hash.put("surname", "Smith");
339+
hash.put("company", "Redis");
340+
hash.put("age", "29");
341+
jedis.hset("user-session:123", hash);
342+
System.out.println(jedis.hgetAll("user-session:123"));
343+
// Prints: {name=John, surname=Smith, company=Redis, age=29}
344+
}
345+
}
346+
}
347+
```
348+
349+
Because adding a `try-with-resources` block for each command can be cumbersome, consider using `JedisPooled` as an easier way to pool connections. `JedisPooled`, added in Jedis version 4.0.0, provides capabilities similar to `JedisPool` but with a more straightforward API.
350+
351+
```java
352+
import redis.clients.jedis.JedisPooled;
353+
354+
//...
320355

321-
### Configuring a connection pool
356+
JedisPooled jedis = new JedisPooled("localhost", 6379);
357+
jedis.set("foo", "bar");
358+
System.out.println(jedis.get("foo")); // prints "bar"
359+
```
322360

323-
As mentioned in the previous section, use `JedisPool` or `JedisPooled` to create a connection pool.
324-
`JedisPooled`, added in Jedis version 4.0.0, provides capabilities similar to `JedisPool` but with a more straightforward API.
325361
A connection pool holds a specified number of connections, creates more connections when necessary, and terminates them when they are no longer needed.
326362

327363
Here is a simplified connection lifecycle in a pool:
@@ -367,6 +403,11 @@ poolConfig.setTimeBetweenEvictionRuns(Duration.ofSeconds(1));
367403
JedisPooled jedis = new JedisPooled(poolConfig, "localhost", 6379);
368404
```
369405

406+
## Production usage
407+
408+
The following sections explain how to handle situations that may occur
409+
in your production environment.
410+
370411
### Timeouts
371412

372413
To set a timeout for a connection, use the `JedisPooled` or `JedisPool` constructor with the `timeout` parameter, or use `JedisClientConfig` with the `socketTimeout` and `connectionTimeout` parameters:

0 commit comments

Comments
 (0)