Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
374 changes: 374 additions & 0 deletions content/develop/clients/connection-urls.md

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions content/develop/clients/dotnet/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ db.StringSet("foo", "bar");
Console.WriteLine(db.StringGet("foo")); // prints bar
```

> [!NOTE]
> Unlike other clients, StackExchange.Redis doesn't support
> [Connection URLs](/content/develop/clients/connection-urls.md#stackexchangeredis-and-nredisstack-net)
> but it does support its own similar configuration string format.
> See [Connection URLs](/content/develop/clients/connection-urls.md#stackexchangeredis-and-nredisstack-net)
> to learn how to convert a standard URL to a configuration string.

## Connect to a Redis cluster

The basic connection will use the
Expand Down
7 changes: 6 additions & 1 deletion content/develop/clients/go/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Then connect to localhost on port 6379 and add a
{{< clients-example set="landing" step="connect" lang_filter="Go" description="Foundational: Connect to a Redis server and establish a client connection" difficulty="beginner" >}}
{{< /clients-example >}}

You can also connect using a connection string:
You can also connect using a connection URL:

```go
opt, err := redis.ParseURL("redis://<user>:<pass>@localhost:6379/<db>")
Expand All @@ -66,6 +66,11 @@ if err != nil {
client := redis.NewClient(opt)
```

> [!NOTE]
> go-redis supports [connection URLs](/content/develop/clients/connection-urls.md#go-redis-go) through `redis.ParseURL()`.
> A URL can set the host, port, credentials, database, and whether to use TLS,
> so you can use one instead of passing those options separately.

After connecting, you can test the connection by storing and retrieving
a simple [string](/content/develop/data-types/strings/_index.md):

Expand Down
7 changes: 6 additions & 1 deletion content/develop/clients/go/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {
}
```

You can also connect using a connection string:
You can also connect using a connection URL:

```go
opt, err := redis.ParseURL("redis://<user>:<pass>@localhost:6379/<db>")
Expand All @@ -47,6 +47,11 @@ if err != nil {
client := redis.NewClient(opt)
```

> [!NOTE]
> go-redis supports [connection URLs](/content/develop/clients/connection-urls.md#go-redis-go) through `redis.ParseURL()`.
> A URL can set the host, port, credentials, database, and whether to use TLS,
> so you can use one instead of passing those options separately.

After connecting, you can test the connection by storing and retrieving
a simple [string](/content/develop/data-types/strings/_index.md):

Expand Down
5 changes: 5 additions & 0 deletions content/develop/clients/ioredis/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ const redis = new Redis({
});
```

> [!NOTE]
> ioredis supports [connection URLs](/content/develop/clients/connection-urls.md#ioredis-javascript) through the `Redis` constructor.
> A URL can set the host, port, credentials, database, and whether to use TLS,
> so you can use one instead of passing those options separately.

Store and retrieve a simple string.

```js
Expand Down
5 changes: 5 additions & 0 deletions content/develop/clients/jedis/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public class Main {
}
```

> [!NOTE]
> Jedis supports [connection URLs](/content/develop/clients/connection-urls.md#jedis-java) through `RedisClient.create()`.
> A URL can set the host, port, credentials, database, and whether to use TLS,
> so you can use one instead of passing those options separately.

After you have connected, you can check the connection by storing and
retrieving a simple string value:

Expand Down
5 changes: 5 additions & 0 deletions content/develop/clients/lettuce/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public class ConnectBasicTest {
}
```

> [!NOTE]
> Lettuce supports [connection URLs](/content/develop/clients/connection-urls.md#lettuce-java) through `RedisClient.create()`.
> A URL can set the host, port, credentials, database, and whether to use TLS,
> so you can use one instead of passing those options separately.

## Connect to a Redis cluster

To connect to a Redis cluster, use `RedisClusterClient`.
Expand Down
8 changes: 7 additions & 1 deletion content/develop/clients/nodejs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,19 @@ Store and retrieve a map.

{{< jupyter-example set="landing" step="set_get_hash" depends="connect" lang_filter="Node.js" description="Foundational: Store and retrieve hash data structures using HSET and HGET commands" difficulty="beginner" />}}

To connect to a different host or port, use a connection string in the format `redis[s]://[[username][:password]@][host][:port][/db-number]`:
To connect to a different host or port, use a connection URL:

```js
createClient({
url: 'redis://alice:foobared@awesome.redis.server:6380'
});
```

> [!NOTE]
> node-redis supports [connection URLs](/content/develop/clients/connection-urls.md#node-redis-javascript) through the `url` option of `createClient()`.
> A URL can set the host, port, credentials, database, and whether to use TLS,
> so you can use one instead of passing those options separately.

To check if the client is connected and ready to send commands, use `client.isReady`, which returns a Boolean. `client.isOpen` is also available. This returns `true` when the client's underlying socket is open, and `false` when it isn't (for example, when the client is still connecting or reconnecting after a network error).

When you have finished using a connection, close it with `client.quit()`.
Expand Down
9 changes: 8 additions & 1 deletion content/develop/clients/nodejs/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,20 @@ console.log(JSON.stringify(userSession, null, 2));
*/
```

To connect to a different host or port, use a connection string in the format `redis[s]://[[username][:password]@][host][:port][/db-number]`:
To connect to a different host or port, use a
[connection URL](/content/develop/clients/connection-urls.md#node-redis-javascript):

```js
createClient({
url: 'redis://alice:foobared@awesome.redis.server:6380'
});
```

> [!NOTE]
> A [connection URL](/content/develop/clients/connection-urls.md#node-redis-javascript) can
> also set the host, port, credentials, database, and whether to use TLS,
> so you can use one instead of passing those options separately.

To check if the client is connected and ready to send commands, use `client.isReady`, which returns a Boolean. `client.isOpen` is also available. This returns `true` when the client's underlying socket is open, and `false` when it isn't (for example, when the client is still connecting or reconnecting after a network error).

## Connect to a Redis cluster
Expand Down
5 changes: 5 additions & 0 deletions content/develop/clients/php/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ $r = new PredisClient([
]);
```

> [!NOTE]
> Predis supports [connection URLs](/content/develop/clients/connection-urls.md#predis-php) through the `PredisClient` constructor.
> A URL can set the host, port, credentials, database, and whether to use TLS,
> so you can use one instead of passing those options separately.

Store and retrieve a simple string to test the connection:

```php
Expand Down
5 changes: 5 additions & 0 deletions content/develop/clients/redis-py/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ Connect to localhost on port 6379, set a value in Redis, and retrieve it. All re
r = redis.Redis(host='localhost', port=6379, decode_responses=True)
```

> [!NOTE]
> redis-py supports [connection URLs](/content/develop/clients/connection-urls.md#redis-py-python) through `redis.from_url()`.
> A URL can set the host, port, credentials, database, and whether to use TLS,
> so you can use one instead of passing those options separately.

Store and retrieve a simple string.

```python
Expand Down
5 changes: 5 additions & 0 deletions content/develop/clients/ruby/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ Connect to localhost on port 6379:

{{< jupyter-example set="landing" step="connect" lang_filter="Ruby" description="Foundational: Connect to a Redis server and establish a client connection" difficulty="beginner" />}}

> [!NOTE]
> redis-rb supports [connection URLs](/content/develop/clients/connection-urls.md#redis-rb-ruby) through the `url` option of `Redis.new`.
> A URL can set the host, port, credentials, database, and whether to use TLS,
> so you can use one instead of passing those options separately.

Store and retrieve a simple string.

{{< jupyter-example set="landing" step="set_get_string" depends="connect" lang_filter="Ruby" description="Foundational: Set and retrieve string values using SET and GET commands" difficulty="beginner" />}}
Expand Down
5 changes: 5 additions & 0 deletions content/develop/clients/rust/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ The following example shows the simplest way to connect to a Redis server:
{{< clients-example set="landing" step="connect" lang_filter="Rust-Sync,Rust-Async" description="Foundational: Connect to a Redis server and establish a client connection" difficulty="beginner" >}}
{{< /clients-example >}}

> [!NOTE]
> redis-rs supports [connection URLs](/content/develop/clients/connection-urls.md#redis-rs-rust) through `Client::open()`.
> A URL can set the host, port, credentials, database, and whether to use TLS,
> so you can use one instead of passing those options separately.

After connecting, you can test the connection by storing and retrieving
a simple [string](/content/develop/data-types/strings/_index.md):

Expand Down
Loading