diff --git a/README.md b/README.md
index 6567fdf44..049d530e6 100644
--- a/README.md
+++ b/README.md
@@ -21,17 +21,17 @@ used in the world's biggest online commerce company [Alibaba](http://www.alibaba
0. Full-featured. It supports [Cluster](http://redis.io/topics/cluster-tutorial), [Sentinel](http://redis.io/topics/sentinel), [Pipelining](http://redis.io/topics/pipelining) and of course [Lua scripting](http://redis.io/commands/eval) & [Pub/Sub](http://redis.io/topics/pubsub) (with the support of binary messages).
1. High performance.
-2. Delightful API. It works with Node callbacks and Native promises.
-3. Transformation of command arguments and replies.
-4. Transparent key prefixing.
-5. Abstraction for Lua scripting, allowing you to define custom commands.
-6. Support for binary data.
-7. Support for TLS.
-8. Support for offline queue and ready checking.
-9. Support for ES6 types, such as `Map` and `Set`.
-10. Support for GEO commands (Redis 3.2 Unstable).
-11. Sophisticated error handling strategy.
-12. Support for NAT mapping.
+1. Delightful API. It works with Node callbacks and Native promises.
+1. Transformation of command arguments and replies.
+1. Transparent key prefixing.
+1. Abstraction for Lua scripting, allowing you to define custom commands.
+1. Support for binary data.
+1. Support for TLS.
+1. Support for offline queue and ready checking.
+1. Support for ES6 types, such as `Map` and `Set`.
+1. Support for GEO commands (Redis 3.2 Unstable).
+1. Sophisticated error handling strategy.
+1. Support for NAT mapping.
# Links
@@ -120,7 +120,7 @@ new Redis({
});
```
-You can also specify connection options as a [`redis://` URL](http://www.iana.org/assignments/uri-schemes/prov/redis):
+You can also specify connection options as a [`redis://` URL](http://www.iana.org/assignments/uri-schemes/prov/redis) or [`rediss://` URL](https://www.iana.org/assignments/uri-schemes/prov/rediss) when using [TLS encryption](#tls-options):
```javascript
// Connect to 127.0.0.1:6380, db 4, using password "authpassword":
@@ -703,6 +703,12 @@ var redis = new Redis({
});
```
+Alternatively, specify the connection through a [`rediss://` URL](https://www.iana.org/assignments/uri-schemes/prov/rediss).
+
+```javascript
+var redis = new Redis("rediss://redis.my-service.com");
+```
+
## Sentinel
@@ -942,7 +948,7 @@ However there are some differences when using transaction and pipeline in Cluste
0. All keys in a pipeline should belong to the same slot since ioredis sends all commands in a pipeline to the same node.
1. You can't use `multi` without pipeline (aka `cluster.multi({ pipeline: false })`). This is because when you call `cluster.multi({ pipeline: false })`, ioredis doesn't know which node the `multi` command should be sent to.
-2. Chaining custom commands in the pipeline is not supported in Cluster mode.
+1. Chaining custom commands in the pipeline is not supported in Cluster mode.
When any commands in a pipeline receives a `MOVED` or `ASK` error, ioredis will resend the whole pipeline to the specified node automatically if all of the following conditions are satisfied:
diff --git a/lib/redis/index.ts b/lib/redis/index.ts
index 0bed65e2d..9524eee7e 100644
--- a/lib/redis/index.ts
+++ b/lib/redis/index.ts
@@ -110,6 +110,7 @@ var debug = Debug("redis");
* var unixSocketRedis2 = new Redis('/tmp/echo.sock');
* var urlRedis = new Redis('redis://user:password@redis-service.com:6379/');
* var urlRedis2 = new Redis('//localhost:6379');
+ * var urlRedisTls = new Redis('rediss://user:password@redis-service.com:6379/');
* var authedRedis = new Redis(6380, '192.168.100.1', { password: 'password' });
* ```
*/
diff --git a/lib/utils/index.ts b/lib/utils/index.ts
index b9676f166..a97bd288d 100644
--- a/lib/utils/index.ts
+++ b/lib/utils/index.ts
@@ -260,7 +260,7 @@ export function parseURL(url) {
result.password = parsed.auth.split(":")[1];
}
if (parsed.pathname) {
- if (parsed.protocol === "redis:") {
+ if (parsed.protocol === "redis:" || parsed.protocol === "rediss:") {
if (parsed.pathname.length > 1) {
result.db = parsed.pathname.slice(1);
}
@@ -274,6 +274,9 @@ export function parseURL(url) {
if (parsed.port) {
result.port = parsed.port;
}
+ if (parsed.protocol === "rediss:") {
+ result.tls = true;
+ }
defaults(result, parsed.query);
return result;
diff --git a/test/unit/utils.ts b/test/unit/utils.ts
index 6aa90d8d8..7993b12dd 100644
--- a/test/unit/utils.ts
+++ b/test/unit/utils.ts
@@ -192,6 +192,16 @@ describe("utils", function() {
expect(utils.parseURL("redis://127.0.0.1/")).to.eql({
host: "127.0.0.1"
});
+ expect(
+ utils.parseURL("rediss://user:pass@127.0.0.1:6380/4?key=value")
+ ).to.eql({
+ tls: true,
+ host: "127.0.0.1",
+ port: "6380",
+ db: "4",
+ password: "pass",
+ key: "value"
+ });
});
});