Skip to content

Commit e604e1d

Browse files
committed
Merge branch 'main' into DOC-4928
2 parents 39d0ed6 + 07a1e5d commit e604e1d

File tree

89 files changed

+4620
-2097
lines changed

Some content is hidden

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

89 files changed

+4620
-2097
lines changed

.github/workflows/redisvl_docs_sync.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,15 @@ jobs:
107107
108108
# Convert jupyter notebooks to markdown
109109
jupyter nbconvert --to markdown build/jupyter_execute/user_guide/*.ipynb --output-dir redis_vl_hugo/user_guide/ 2>/dev/null
110+
jupyter nbconvert --to markdown build/jupyter_execute/user_guide/release_guide/*.ipynb --output-dir redis_vl_hugo/user_guide/release_guide/ 2>/dev/null
110111
jupyter nbconvert --to markdown build/jupyter_execute/overview/cli.ipynb --output-dir redis_vl_hugo/overview/ 2>/dev/null
111112
112113
# Prepare markdown files
113114
rsync -a ./build/markdown/api/ ./redis_vl_hugo/api/ --exclude=index.md
114115
cp ./build/markdown/overview/installation.md ./redis_vl_hugo/overview/installation.md
115116
116117
# Format markdown files
118+
shopt -s globstar
117119
markdown_pages=(./redis_vl_hugo/**/*.md)
118120
119121
for markdown_page in "${markdown_pages[@]}"; do
@@ -208,19 +210,21 @@ jobs:
208210
# Format _index.md pages
209211
cp ./build/markdown/api/index.md ./redis_vl_hugo/api/_index.md
210212
cp ./build/markdown/user_guide/index.md ./redis_vl_hugo/user_guide/_index.md
213+
cp ./build/markdown/user_guide/release_guide/index.md ./redis_vl_hugo/user_guide/release_guide/_index.md
211214
cp ./build/markdown/overview/index.md ./redis_vl_hugo/overview/_index.md
212215
213216
index_markdown_pages=(
214217
./redis_vl_hugo/api/_index.md
215218
./redis_vl_hugo/user_guide/_index.md
219+
./redis_vl_hugo/user_guide/release_guide/_index.md
216220
./redis_vl_hugo/overview/_index.md
217221
)
218222
219223
for index_markdown_page in "${index_markdown_pages[@]}"; do
220224
format "${index_markdown_page}"
221225
222226
# Fix relrefs by removing .md extension and references to numbered pages
223-
sed -E -i 's/\.md/\//g; s/\([0-9]+_/\(/g' "${index_markdown_page}"
227+
sed -E -i 's/\.md/\//g; s/\([0-9]{2}_/\(/g; s/\/index\//\//g' "${index_markdown_page}"
224228
done
225229
226230
# Rename user guides to strip leading numbers from filename

content/develop/clients/dotnet/condexec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ categories:
1212
description: Understand how `NRedisStack` uses conditional execution
1313
linkTitle: Conditional execution
1414
title: Conditional execution
15-
weight: 6
15+
weight: 60
1616
---
1717

1818
Most Redis client libraries use transactions with the

content/develop/clients/dotnet/connect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ categories:
1212
description: Connect your .NET application to a Redis database
1313
linkTitle: Connect
1414
title: Connect to the server
15-
weight: 2
15+
weight: 20
1616
---
1717

1818
## Basic connection
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
categories:
3+
- docs
4+
- develop
5+
- stack
6+
- oss
7+
- rs
8+
- rc
9+
- oss
10+
- kubernetes
11+
- clients
12+
description: Get your NRedisStack app ready for production
13+
linkTitle: Production usage
14+
title: Production usage
15+
weight: 70
16+
---
17+
18+
This guide offers recommendations to get the best reliability and
19+
performance in your production environment.
20+
21+
## Checklist
22+
23+
Each item in the checklist below links to the section
24+
for a recommendation. Use the checklist icons to record your
25+
progress in implementing the recommendations.
26+
27+
{{< checklist "dotnetprodlist" >}}
28+
{{< checklist-item "#event-handling" >}}Event handling{{< /checklist-item >}}
29+
{{< checklist-item "#timeouts" >}}Timeouts{{< /checklist-item >}}
30+
{{< checklist-item "#exception-handling" >}}Exception handling{{< /checklist-item >}}
31+
{{< /checklist >}}
32+
33+
## Recommendations
34+
35+
The sections below offer recommendations for your production environment. Some
36+
of them may not apply to your particular use case.
37+
38+
### Event handling
39+
40+
The `ConnectionMultiplexer` class publishes several different types of
41+
[events](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/events/)
42+
for situations such as configuration changes and connection failures.
43+
Use these events to record server activity in a log, which you can then use
44+
to monitor performance and diagnose problems when they occur.
45+
See
46+
the StackExchange.Redis
47+
[Events](https://stackexchange.github.io/StackExchange.Redis/Events)
48+
page for the full list of events.
49+
50+
#### Server notification events
51+
52+
Some servers (such as Azure Cache for Redis) send notification events shortly
53+
before scheduled maintenance is due to happen. You can use code like the
54+
following to respond to these events (see the
55+
[StackExchange.Redis](https://stackexchange.github.io/StackExchange.Redis/ServerMaintenanceEvent)
56+
docs for the full list of supported events). For example, you could
57+
inform users who try to connect that service is temporarily unavailable
58+
rather than letting them run into errors.
59+
60+
```cs
61+
using NRedisStack;
62+
using StackExchange.Redis;
63+
64+
ConnectionMultiplexer muxer = ConnectionMultiplexer.Connect("localhost:6379");
65+
66+
muxer.ServerMaintenanceEvent += (object sender, ServerMaintenanceEvent e) => {
67+
// Identify the event and respond to it here.
68+
Console.WriteLine($"Maintenance event: {e.RawMessage}");
69+
};
70+
```
71+
72+
### Timeouts
73+
74+
If a network or server error occurs while your code is opening a
75+
connection or issuing a command, it can end up hanging indefinitely.
76+
To prevent this, `NRedisStack` sets timeouts for socket
77+
reads and writes and for opening connections.
78+
79+
By default, the timeout is five seconds for all operations, but
80+
you can set the time (in milliseconds) separately for connections
81+
and commands using the `ConnectTimeout`, `SyncTimeout`, and
82+
`AsyncTimeout` configuration options:
83+
84+
```cs
85+
var muxer = ConnectionMultiplexer.Connect(new ConfigurationOptions {
86+
ConnectTimeout = 1000, // 1 second timeout for connections.
87+
SyncTimeout = 2000, // 2 seconds for synchronous commands.
88+
AsyncTimeout = 3000 // 3 seconds for asynchronous commands.
89+
.
90+
.
91+
});
92+
93+
var db = muxer.GetDatabase();
94+
```
95+
96+
The default timeouts are a good starting point, but you may be able
97+
to improve performance by adjusting the values to suit your use case.
98+
99+
### Exception handling
100+
101+
Redis handles many errors using return values from commands, but there
102+
are also situations where exceptions can be thrown. In production code,
103+
you should handle exceptions as they occur. The list below describes some
104+
the most common Redis exceptions:
105+
106+
- `RedisConnectionException`: Thrown when a connection attempt fails.
107+
- `RedisTimeoutException`: Thrown when a command times out.
108+
- `RedisCommandException`: Thrown when you issue an invalid command.
109+
- `RedisServerException`: Thrown when you attempt an invalid operation
110+
(for example, trying to access a
111+
[stream entry]({{< relref "/develop/data-types/streams#entry-ids" >}})
112+
using an invalid ID).

content/develop/clients/dotnet/queryjson.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ categories:
1212
description: Learn how to use the Redis query engine with JSON and hash documents.
1313
linkTitle: Index and query documents
1414
title: Index and query documents
15-
weight: 2
15+
weight: 30
1616
---
1717

1818
This example shows how to create a

content/develop/clients/dotnet/transpipe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ categories:
1212
description: Learn how to use Redis pipelines and transactions
1313
linkTitle: Pipelines/transactions
1414
title: Pipelines and transactions
15-
weight: 5
15+
weight: 50
1616
---
1717

1818
Redis lets you send a sequence of commands to the server together in a batch.

content/develop/clients/dotnet/vecsearch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ categories:
1212
description: Learn how to index and query vector embeddings with Redis
1313
linkTitle: Index and query vectors
1414
title: Index and query vectors
15-
weight: 3
15+
weight: 40
1616
---
1717

1818
[Redis Query Engine]({{< relref "/develop/interact/search-and-query" >}})

content/develop/clients/nodejs/connect.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ await cluster.set('foo', 'bar');
9494
const value = await cluster.get('foo');
9595
console.log(value); // returns 'bar'
9696

97-
await cluster.quit();
97+
await cluster.close();
9898
```
9999

100100
## Connect to your production Redis with TLS
@@ -123,15 +123,21 @@ await client.set('foo', 'bar');
123123
const value = await client.get('foo');
124124
console.log(value) // returns 'bar'
125125

126-
await client.disconnect();
126+
await client.destroy();
127127
```
128128

129129
You can also use discrete parameters and UNIX sockets. Details can be found in the [client configuration guide](https://github.com/redis/node-redis/blob/master/docs/client-configuration.md).
130130

131131
## Reconnect after disconnection
132132

133-
By default, `node-redis` doesn't attempt to reconnect automatically when
134-
the connection to the server is lost. However, you can set the
133+
`node-redis` can attempt to reconnect automatically when
134+
the connection to the server is lost. By default, it will retry
135+
the connection using an
136+
[exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff)
137+
strategy with some random "jitter" added to avoid multiple
138+
clients retrying in sync with each other.
139+
140+
You can also set the
135141
`socket.reconnectionStrategy` field in the configuration to decide
136142
whether to try to reconnect and how to approach it. Choose one of the following values for
137143
`socket.reconnectionStrategy`:
@@ -159,19 +165,18 @@ from the function can be any of the following:
159165
no attempt was made to reconnect.
160166

161167
The example below shows a `reconnectionStrategy` function that implements a
162-
custom [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff)
163-
strategy:
168+
custom exponential backoff strategy:
164169

165170
```js
166171
createClient({
167172
socket: {
168173
reconnectStrategy: retries => {
169-
// Generate a random jitter between 0 – 200 ms:
170-
const jitter = Math.floor(Math.random() * 200);
174+
// Generate a random jitter between 0 – 100 ms:
175+
const jitter = Math.floor(Math.random() * 100);
171176

172-
// Delay is an exponential back off, (times^2) * 50 ms, with a
173-
// maximum value of 2000 ms:
174-
const delay = Math.min(Math.pow(2, retries) * 50, 2000);
177+
// Delay is an exponential backoff, (2^retries) * 50 ms, with a
178+
// maximum value of 3000 ms:
179+
const delay = Math.min(Math.pow(2, retries) * 50, 3000);
175180

176181
return delay + jitter;
177182
}
@@ -193,6 +198,12 @@ related to connection:
193198
parameter. This is usually a network issue such as "Socket closed unexpectedly".
194199
- `reconnecting`: (No parameters) The client is about to try reconnecting after the
195200
connection was lost due to an error.
201+
- `sharded-channel-moved`: The cluster slot of a subscribed
202+
[sharded pub/sub channel]({{< relref "/develop/interact/pubsub#sharded-pubsub" >}})
203+
has been moved to another shard. Note that when you use a
204+
[`RedisCluster`](#connect-to-a-redis-cluster) connection, this event is automatically
205+
handled for you. See
206+
[`sharded-channel-moved` event](https://github.com/redis/node-redis/blob/master/docs/pub-sub.md#sharded-channel-moved-event) for more information.
196207

197208
Use code like the following to respond to these events:
198209

content/develop/clients/nodejs/produsage.md

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,22 @@ title: Production usage
1515
weight: 5
1616
---
1717

18-
The following sections explain how to handle situations that may occur
19-
in your production environment.
18+
This guide offers recommendations to get the best reliability and
19+
performance in your production environment.
20+
21+
## Checklist
22+
23+
Each item in the checklist below links to the section
24+
for a recommendation. Use the checklist icons to record your
25+
progress in implementing the recommendations.
26+
27+
{{< checklist "nodeprodlist" >}}
28+
{{< checklist-item "#handling-errors" >}}Handling errors{{< /checklist-item >}}
29+
{{< checklist-item "#handling-reconnections" >}}Handling reconnections{{< /checklist-item >}}
30+
{{< checklist-item "#timeouts" >}}Timeouts{{< /checklist-item >}}
31+
{{< /checklist >}}
32+
33+
## Recommendations
2034

2135
### Handling errors
2236

@@ -41,36 +55,13 @@ client.on('error', error => {
4155

4256
### Handling reconnections
4357

44-
If network issues or other problems unexpectedly close the socket, the client will reject all commands already sent, since the server might have already executed them.
45-
The rest of the pending commands will remain queued in memory until a new socket is established.
46-
This behaviour is controlled by the `enableOfflineQueue` option, which is enabled by default.
47-
48-
The client uses `reconnectStrategy` to decide when to attempt to reconnect.
49-
The default strategy is to calculate the delay before each attempt based on the attempt number `Math.min(retries * 50, 500)`. You can customize this strategy by passing a supported value to `reconnectStrategy` option:
50-
51-
52-
1. Define a callback `(retries: number, cause: Error) => false | number | Error` **(recommended)**
53-
```typescript
54-
const client = createClient({
55-
socket: {
56-
reconnectStrategy: function(retries) {
57-
if (retries > 20) {
58-
console.log("Too many attempts to reconnect. Redis connection was terminated");
59-
return new Error("Too many retries.");
60-
} else {
61-
return retries * 500;
62-
}
63-
}
64-
}
65-
});
66-
client.on('error', error => console.error('Redis client error:', error));
67-
```
68-
In the provided reconnection strategy callback, the client attempts to reconnect up to 20 times with a delay of `retries * 500` milliseconds between attempts.
69-
After approximately two minutes, the client logs an error message and terminates the connection if the maximum retry limit is exceeded.
70-
71-
72-
2. Use a numerical value to set a fixed delay in milliseconds.
73-
3. Use `false` to disable reconnection attempts. This option should only be used for testing purposes.
58+
When the socket closes unexpectedly (without calling the `quit()` or `disconnect()` methods),
59+
the client can automatically restore the connection. A simple
60+
[exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) strategy
61+
for reconnection is enabled by default, but you can replace this with your
62+
own custom strategy. See
63+
[Reconnect after disconnection]({{< relref "/develop/clients/nodejs/connect#reconnect-after-disconnection" >}})
64+
for more information.
7465

7566
### Timeouts
7667

content/develop/clients/nodejs/queryjson.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ Add the following dependencies:
3434
```js
3535
import {
3636
createClient,
37-
SchemaFieldTypes,
38-
AggregateGroupByReducers,
39-
AggregateSteps,
37+
SCHEMA_FIELD_TYPE,
38+
FT_AGGREGATE_GROUP_BY_REDUCERS,
39+
FT_AGGREGATE_STEPS,
4040
} from 'redis';
4141
```
4242

0 commit comments

Comments
 (0)