@keyv/redis 2.1.1 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nyc_output/c17c3934-1699-442d-8326-3e558a85ef96.json +1 -0
- package/.nyc_output/e01c4be3-7f2c-40c1-b506-7a632572f30b.json +1 -0
- package/.nyc_output/processinfo/c17c3934-1699-442d-8326-3e558a85ef96.json +1 -0
- package/.nyc_output/processinfo/e01c4be3-7f2c-40c1-b506-7a632572f30b.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/README.md +5 -5
- package/package.json +17 -16
- package/src/index.js +8 -11
- package/test/test.js +36 -0
- package/LICENSE +0 -21
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/redis/src/index.js":{"path":"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/redis/src/index.js","statementMap":{"0":{"start":{"line":1,"column":21},"end":{"line":1,"column":38}},"1":{"start":{"line":2,"column":14},"end":{"line":2,"column":32}},"2":{"start":{"line":6,"column":2},"end":{"line":6,"column":10}},"3":{"start":{"line":7,"column":2},"end":{"line":7,"column":25}},"4":{"start":{"line":9,"column":2},"end":{"line":14,"column":3}},"5":{"start":{"line":10,"column":3},"end":{"line":10,"column":20}},"6":{"start":{"line":12,"column":3},"end":{"line":12,"column":81}},"7":{"start":{"line":13,"column":3},"end":{"line":13,"column":48}},"8":{"start":{"line":16,"column":2},"end":{"line":16,"column":61}},"9":{"start":{"line":16,"column":34},"end":{"line":16,"column":59}},"10":{"start":{"line":20,"column":2},"end":{"line":20,"column":39}},"11":{"start":{"line":24,"column":2},"end":{"line":31,"column":6}},"12":{"start":{"line":26,"column":4},"end":{"line":28,"column":5}},"13":{"start":{"line":27,"column":5},"end":{"line":27,"column":22}},"14":{"start":{"line":30,"column":4},"end":{"line":30,"column":17}},"15":{"start":{"line":35,"column":2},"end":{"line":37,"column":3}},"16":{"start":{"line":36,"column":3},"end":{"line":36,"column":37}},"17":{"start":{"line":39,"column":2},"end":{"line":47,"column":59}},"18":{"start":{"line":41,"column":4},"end":{"line":43,"column":5}},"19":{"start":{"line":42,"column":5},"end":{"line":42,"column":50}},"20":{"start":{"line":45,"column":4},"end":{"line":45,"column":38}},"21":{"start":{"line":47,"column":15},"end":{"line":47,"column":57}},"22":{"start":{"line":51,"column":2},"end":{"line":53,"column":28}},"23":{"start":{"line":52,"column":18},"end":{"line":53,"column":26}},"24":{"start":{"line":53,"column":16},"end":{"line":53,"column":25}},"25":{"start":{"line":57,"column":2},"end":{"line":59,"column":26}},"26":{"start":{"line":58,"column":17},"end":{"line":58,"column":66}},"27":{"start":{"line":59,"column":15},"end":{"line":59,"column":24}},"28":{"start":{"line":63,"column":0},"end":{"line":63,"column":27}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":5,"column":1},"end":{"line":5,"column":2}},"loc":{"start":{"line":5,"column":27},"end":{"line":17,"column":2}},"line":5},"1":{"name":"(anonymous_1)","decl":{"start":{"line":16,"column":25},"end":{"line":16,"column":26}},"loc":{"start":{"line":16,"column":34},"end":{"line":16,"column":59}},"line":16},"2":{"name":"(anonymous_2)","decl":{"start":{"line":19,"column":1},"end":{"line":19,"column":2}},"loc":{"start":{"line":19,"column":17},"end":{"line":21,"column":2}},"line":19},"3":{"name":"(anonymous_3)","decl":{"start":{"line":23,"column":1},"end":{"line":23,"column":2}},"loc":{"start":{"line":23,"column":10},"end":{"line":32,"column":2}},"line":23},"4":{"name":"(anonymous_4)","decl":{"start":{"line":25,"column":9},"end":{"line":25,"column":10}},"loc":{"start":{"line":25,"column":18},"end":{"line":31,"column":4}},"line":25},"5":{"name":"(anonymous_5)","decl":{"start":{"line":34,"column":1},"end":{"line":34,"column":2}},"loc":{"start":{"line":34,"column":22},"end":{"line":48,"column":2}},"line":34},"6":{"name":"(anonymous_6)","decl":{"start":{"line":40,"column":9},"end":{"line":40,"column":10}},"loc":{"start":{"line":40,"column":15},"end":{"line":46,"column":4}},"line":40},"7":{"name":"(anonymous_7)","decl":{"start":{"line":47,"column":9},"end":{"line":47,"column":10}},"loc":{"start":{"line":47,"column":15},"end":{"line":47,"column":57}},"line":47},"8":{"name":"(anonymous_8)","decl":{"start":{"line":50,"column":1},"end":{"line":50,"column":2}},"loc":{"start":{"line":50,"column":13},"end":{"line":54,"column":2}},"line":50},"9":{"name":"(anonymous_9)","decl":{"start":{"line":52,"column":9},"end":{"line":52,"column":10}},"loc":{"start":{"line":52,"column":18},"end":{"line":53,"column":26}},"line":52},"10":{"name":"(anonymous_10)","decl":{"start":{"line":53,"column":10},"end":{"line":53,"column":11}},"loc":{"start":{"line":53,"column":16},"end":{"line":53,"column":25}},"line":53},"11":{"name":"(anonymous_11)","decl":{"start":{"line":56,"column":1},"end":{"line":56,"column":2}},"loc":{"start":{"line":56,"column":9},"end":{"line":60,"column":2}},"line":56},"12":{"name":"(anonymous_12)","decl":{"start":{"line":58,"column":9},"end":{"line":58,"column":10}},"loc":{"start":{"line":58,"column":17},"end":{"line":58,"column":66}},"line":58},"13":{"name":"(anonymous_13)","decl":{"start":{"line":59,"column":9},"end":{"line":59,"column":10}},"loc":{"start":{"line":59,"column":15},"end":{"line":59,"column":24}},"line":59}},"branchMap":{"0":{"loc":{"start":{"line":9,"column":2},"end":{"line":14,"column":3}},"type":"if","locations":[{"start":{"line":9,"column":2},"end":{"line":14,"column":3}},{"start":{"line":9,"column":2},"end":{"line":14,"column":3}}],"line":9},"1":{"loc":{"start":{"line":9,"column":6},"end":{"line":9,"column":58}},"type":"binary-expr","locations":[{"start":{"line":9,"column":6},"end":{"line":9,"column":26}},{"start":{"line":9,"column":30},"end":{"line":9,"column":58}}],"line":9},"2":{"loc":{"start":{"line":12,"column":31},"end":{"line":12,"column":70}},"type":"cond-expr","locations":[{"start":{"line":12,"column":57},"end":{"line":12,"column":64}},{"start":{"line":12,"column":67},"end":{"line":12,"column":70}}],"line":12},"3":{"loc":{"start":{"line":26,"column":4},"end":{"line":28,"column":5}},"type":"if","locations":[{"start":{"line":26,"column":4},"end":{"line":28,"column":5}},{"start":{"line":26,"column":4},"end":{"line":28,"column":5}}],"line":26},"4":{"loc":{"start":{"line":35,"column":2},"end":{"line":37,"column":3}},"type":"if","locations":[{"start":{"line":35,"column":2},"end":{"line":37,"column":3}},{"start":{"line":35,"column":2},"end":{"line":37,"column":3}}],"line":35},"5":{"loc":{"start":{"line":41,"column":4},"end":{"line":43,"column":5}},"type":"if","locations":[{"start":{"line":41,"column":4},"end":{"line":43,"column":5}},{"start":{"line":41,"column":4},"end":{"line":43,"column":5}}],"line":41}},"s":{"0":1,"1":1,"2":152,"3":152,"4":152,"5":2,"6":150,"7":150,"8":152,"9":7,"10":287,"11":29,"12":29,"13":11,"14":18,"15":29,"16":1,"17":28,"18":28,"19":1,"20":27,"21":28,"22":5,"23":5,"24":5,"25":127,"26":127,"27":127,"28":1},"f":{"0":152,"1":7,"2":287,"3":29,"4":29,"5":29,"6":28,"7":28,"8":5,"9":5,"10":5,"11":127,"12":127,"13":127},"b":{"0":[2,150],"1":[152,150],"2":[148,2],"3":[11,18],"4":[1,28],"5":[1,27]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"bd8f3b81707d244584617a53dd7adf94e42c4798","contentHash":"c5e135535b639a2ad3a20d9fad0afd67bb707402a023b20709855704d5b485fa"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":null,"pid":12159,"argv":["/Users/jaredwray/.nvm/versions/node/v16.10.0/bin/node","/Users/jaredwray/src/github.com/jaredwray/keyv/packages/redis/node_modules/.bin/ava"],"execArgv":[],"cwd":"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/redis","time":1638740362141,"ppid":12158,"coverageFilename":"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/redis/.nyc_output/c17c3934-1699-442d-8326-3e558a85ef96.json","externalId":"","uuid":"c17c3934-1699-442d-8326-3e558a85ef96","files":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":"c17c3934-1699-442d-8326-3e558a85ef96","pid":12163,"argv":["/Users/jaredwray/.nvm/versions/node/v16.10.0/bin/node","/Users/jaredwray/src/github.com/jaredwray/keyv/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/redis","time":1638740362478,"ppid":12159,"coverageFilename":"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/redis/.nyc_output/e01c4be3-7f2c-40c1-b506-7a632572f30b.json","externalId":"","uuid":"e01c4be3-7f2c-40c1-b506-7a632572f30b","files":["/Users/jaredwray/src/github.com/jaredwray/keyv/packages/redis/src/index.js"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"processes":{"c17c3934-1699-442d-8326-3e558a85ef96":{"parent":null,"children":["e01c4be3-7f2c-40c1-b506-7a632572f30b"]},"e01c4be3-7f2c-40c1-b506-7a632572f30b":{"parent":"c17c3934-1699-442d-8326-3e558a85ef96","children":[]}},"files":{"/Users/jaredwray/src/github.com/jaredwray/keyv/packages/redis/src/index.js":["e01c4be3-7f2c-40c1-b506-7a632572f30b"]},"externalIds":{}}
|
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# @keyv/redis [<img width="100" align="right" src="https://
|
|
1
|
+
# @keyv/redis [<img width="100" align="right" src="https://jaredwray.com/images/keyv.svg" alt="keyv">](https://github.com/jaredwra/keyv)
|
|
2
2
|
|
|
3
3
|
> Redis storage adapter for Keyv
|
|
4
4
|
|
|
5
|
-
[](https://github.com/jaredwray/keyv-redis/actions/workflows/build.yaml)
|
|
6
|
+
[](https://codecov.io/gh/jaredwray/keyv-redis)
|
|
7
7
|
[](https://www.npmjs.com/package/@keyv/redis)
|
|
8
8
|
|
|
9
|
-
Redis storage adapter for [Keyv](https://github.com/
|
|
9
|
+
Redis storage adapter for [Keyv](https://github.com/jaredwray/keyv).
|
|
10
10
|
|
|
11
11
|
TTL functionality is handled directly by Redis so no timestamps are stored and expired keys are cleaned up internally.
|
|
12
12
|
|
|
@@ -57,4 +57,4 @@ const keyv = new Keyv({ store: keyvRedis });
|
|
|
57
57
|
|
|
58
58
|
## License
|
|
59
59
|
|
|
60
|
-
MIT © Luke Childs
|
|
60
|
+
MIT © Jared Wray & Luke Childs
|
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keyv/redis",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Redis storage adapter for Keyv",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "xo && nyc ava",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"coverage": "nyc report --reporter=text-lcov | coveralls"
|
|
8
|
+
"coverage": "nyc report --reporter=text-lcov > coverage.lcov",
|
|
9
|
+
"clean": "rm -rf node_modules && rm -rf .nyc_output && rm -rf coverage.lcov"
|
|
11
10
|
},
|
|
12
11
|
"xo": {
|
|
13
|
-
"extends": "xo-lukechilds"
|
|
12
|
+
"extends": "xo-lukechilds",
|
|
13
|
+
"rules": {
|
|
14
|
+
"unicorn/prefer-module": 0
|
|
15
|
+
}
|
|
14
16
|
},
|
|
15
17
|
"ava": {
|
|
16
18
|
"require": [
|
|
@@ -19,7 +21,7 @@
|
|
|
19
21
|
},
|
|
20
22
|
"repository": {
|
|
21
23
|
"type": "git",
|
|
22
|
-
"url": "git+https://github.com/
|
|
24
|
+
"url": "git+https://github.com/jaredwray/keyv.git"
|
|
23
25
|
},
|
|
24
26
|
"keywords": [
|
|
25
27
|
"redis",
|
|
@@ -32,25 +34,24 @@
|
|
|
32
34
|
"cache",
|
|
33
35
|
"ttl"
|
|
34
36
|
],
|
|
35
|
-
"author": "
|
|
37
|
+
"author": "Jared Wray <me@jaredwray.com> (http://jaredwray.com)",
|
|
36
38
|
"license": "MIT",
|
|
37
39
|
"bugs": {
|
|
38
|
-
"url": "https://github.com/
|
|
40
|
+
"url": "https://github.com/jaredwray/keyv/issues"
|
|
39
41
|
},
|
|
40
|
-
"homepage": "https://github.com/
|
|
42
|
+
"homepage": "https://github.com/jaredwray/keyv",
|
|
41
43
|
"dependencies": {
|
|
42
|
-
"ioredis": "
|
|
44
|
+
"ioredis": "^4.28.2"
|
|
43
45
|
},
|
|
44
46
|
"devDependencies": {
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"delay": "^
|
|
47
|
+
"@keyv/test-suite": "^1.6.12",
|
|
48
|
+
"ava": "^3.15.0",
|
|
49
|
+
"delay": "^5.0.0",
|
|
48
50
|
"eslint-config-xo-lukechilds": "^1.0.1",
|
|
49
51
|
"keyv": "*",
|
|
50
|
-
"
|
|
51
|
-
"nyc": "^14.1.1",
|
|
52
|
+
"nyc": "^15.1.0",
|
|
52
53
|
"requirable": "^1.0.5",
|
|
53
54
|
"this": "^1.1.0",
|
|
54
|
-
"xo": "^0.
|
|
55
|
+
"xo": "^0.47.0"
|
|
55
56
|
}
|
|
56
57
|
}
|
package/src/index.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
const EventEmitter = require('events');
|
|
4
2
|
const Redis = require('ioredis');
|
|
5
3
|
|
|
6
4
|
class KeyvRedis extends EventEmitter {
|
|
7
|
-
constructor(uri,
|
|
5
|
+
constructor(uri, options) {
|
|
8
6
|
super();
|
|
7
|
+
this.ttlSupport = true;
|
|
9
8
|
|
|
10
|
-
if (uri instanceof Redis) {
|
|
9
|
+
if (uri instanceof Redis || uri instanceof Redis.Cluster) {
|
|
11
10
|
this.redis = uri;
|
|
12
11
|
} else {
|
|
13
|
-
|
|
14
|
-
this.redis = new Redis(
|
|
12
|
+
options = Object.assign({}, typeof uri === 'string' ? { uri } : uri, options);
|
|
13
|
+
this.redis = new Redis(options.uri, options);
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
this.redis.on('error',
|
|
16
|
+
this.redis.on('error', error => this.emit('error', error));
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
_getNamespace() {
|
|
@@ -50,10 +49,8 @@ class KeyvRedis extends EventEmitter {
|
|
|
50
49
|
|
|
51
50
|
delete(key) {
|
|
52
51
|
return this.redis.del(key)
|
|
53
|
-
.then(items =>
|
|
54
|
-
|
|
55
|
-
.then(() => items > 0);
|
|
56
|
-
});
|
|
52
|
+
.then(items => this.redis.srem(this._getNamespace(), key)
|
|
53
|
+
.then(() => items > 0));
|
|
57
54
|
}
|
|
58
55
|
|
|
59
56
|
clear() {
|
package/test/test.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const test = require('ava');
|
|
2
|
+
const keyvTestSuite = require('@keyv/test-suite').default;
|
|
3
|
+
const { keyvOfficialTests } = require('@keyv/test-suite');
|
|
4
|
+
const Keyv = require('keyv');
|
|
5
|
+
const KeyvRedis = require('this');
|
|
6
|
+
const Redis = require('ioredis');
|
|
7
|
+
|
|
8
|
+
const REDIS_HOST = 'localhost';
|
|
9
|
+
const redisURI = `redis://${REDIS_HOST}`;
|
|
10
|
+
|
|
11
|
+
keyvOfficialTests(test, Keyv, redisURI, 'redis://foo');
|
|
12
|
+
|
|
13
|
+
const store = () => new KeyvRedis(redisURI);
|
|
14
|
+
|
|
15
|
+
keyvTestSuite(test, Keyv, store);
|
|
16
|
+
|
|
17
|
+
test('reuse a redis instance', async t => {
|
|
18
|
+
const redis = new Redis(redisURI);
|
|
19
|
+
redis.foo = 'bar';
|
|
20
|
+
const keyv = new KeyvRedis(redis);
|
|
21
|
+
t.is(keyv.redis.foo, 'bar');
|
|
22
|
+
|
|
23
|
+
await keyv.set('foo', 'bar');
|
|
24
|
+
const value = await redis.get('foo');
|
|
25
|
+
t.true(value === 'bar');
|
|
26
|
+
t.true(await keyv.get('foo') === value);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('set an undefined key', async t => {
|
|
30
|
+
const redis = new Redis(redisURI);
|
|
31
|
+
const keyv = new KeyvRedis(redis);
|
|
32
|
+
|
|
33
|
+
await keyv.set('foo2', undefined);
|
|
34
|
+
const result = await keyv.get('foo2');
|
|
35
|
+
t.true(result === undefined);
|
|
36
|
+
});
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2017 Luke Childs
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|