You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: index.js
+41-3Lines changed: 41 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,7 @@
2
2
3
3
varRedisPool=require('sol-redis-pool');
4
4
varEventEmitter=require('events').EventEmitter;
5
+
varredisUrl=require('redis-url');
5
6
6
7
/**
7
8
* The cache manager Redis Store module
@@ -20,11 +21,11 @@ function redisStore(args) {
20
21
21
22
// cache-manager should always pass in args
22
23
/* istanbul ignore next */
23
-
varredisOptions=args||{};
24
+
varredisOptions=getFromUrl(args)||args||{};
24
25
varpoolSettings=redisOptions;
25
26
26
-
redisOptions.host=args.host||'127.0.0.1';
27
-
redisOptions.port=args.port||6379;
27
+
redisOptions.host=redisOptions.host||'127.0.0.1';
28
+
redisOptions.port=redisOptions.port||6379;
28
29
29
30
varpool=newRedisPool(redisOptions,poolSettings);
30
31
@@ -88,6 +89,43 @@ function redisStore(args) {
88
89
};
89
90
}
90
91
92
+
/**
93
+
* Extracts options from an args.url
94
+
* @param {Object} args
95
+
* @param {String} args.url a string in format of redis://[:password@]host[:port][/db-number][?option=value]
96
+
* @returns {Object} the input object args if it is falsy, does not contain url or url is not string, otherwise a new object with own properties of args
97
+
* but with host, port, db, ttl and auth_pass properties overridden by those provided in args.url.
0 commit comments