@keyv/redis 2.1.0 → 2.2.0
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/LICENSE +1 -1
- package/README.md +5 -5
- package/package.json +18 -16
- package/src/index.js +7 -11
package/LICENSE
CHANGED
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,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keyv/redis",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Redis storage adapter for Keyv",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "xo && nyc ava",
|
|
8
|
-
"test:
|
|
9
|
-
"
|
|
10
|
-
"coverage": "nyc report --reporter=text-lcov
|
|
8
|
+
"test:services:start": "docker-compose -f ./test/redis-compose.yaml up -d",
|
|
9
|
+
"test:services:stop": "docker-compose -f ./test/redis-compose.yaml down -v",
|
|
10
|
+
"coverage": "nyc report --reporter=text-lcov > coverage.lcov"
|
|
11
11
|
},
|
|
12
12
|
"xo": {
|
|
13
|
-
"extends": "xo-lukechilds"
|
|
13
|
+
"extends": "xo-lukechilds",
|
|
14
|
+
"rules": {
|
|
15
|
+
"unicorn/prefer-module": 0
|
|
16
|
+
}
|
|
14
17
|
},
|
|
15
18
|
"ava": {
|
|
16
19
|
"require": [
|
|
@@ -19,7 +22,7 @@
|
|
|
19
22
|
},
|
|
20
23
|
"repository": {
|
|
21
24
|
"type": "git",
|
|
22
|
-
"url": "git+https://github.com/
|
|
25
|
+
"url": "git+https://github.com/jaredwray/keyv-redis.git"
|
|
23
26
|
},
|
|
24
27
|
"keywords": [
|
|
25
28
|
"redis",
|
|
@@ -32,25 +35,24 @@
|
|
|
32
35
|
"cache",
|
|
33
36
|
"ttl"
|
|
34
37
|
],
|
|
35
|
-
"author": "
|
|
38
|
+
"author": "Jared Wray <me@jaredwray.com> (http://jaredwray.com)",
|
|
36
39
|
"license": "MIT",
|
|
37
40
|
"bugs": {
|
|
38
|
-
"url": "https://github.com/
|
|
41
|
+
"url": "https://github.com/jaredwray/keyv-redis/issues"
|
|
39
42
|
},
|
|
40
|
-
"homepage": "https://github.com/
|
|
43
|
+
"homepage": "https://github.com/jaredwray/keyv-redis",
|
|
41
44
|
"dependencies": {
|
|
42
|
-
"ioredis": "
|
|
45
|
+
"ioredis": "^4.28.0"
|
|
43
46
|
},
|
|
44
47
|
"devDependencies": {
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"delay": "^
|
|
48
|
+
"@keyv/test-suite": "^1.6.11",
|
|
49
|
+
"ava": "^3.15.0",
|
|
50
|
+
"delay": "^5.0.0",
|
|
48
51
|
"eslint-config-xo-lukechilds": "^1.0.1",
|
|
49
52
|
"keyv": "*",
|
|
50
|
-
"
|
|
51
|
-
"nyc": "^14.1.1",
|
|
53
|
+
"nyc": "^15.1.0",
|
|
52
54
|
"requirable": "^1.0.5",
|
|
53
55
|
"this": "^1.1.0",
|
|
54
|
-
"xo": "^0.
|
|
56
|
+
"xo": "^0.46.4"
|
|
55
57
|
}
|
|
56
58
|
}
|
package/src/index.js
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
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();
|
|
9
7
|
|
|
10
|
-
if (uri instanceof Redis) {
|
|
8
|
+
if (uri instanceof Redis || uri instanceof Redis.Cluster) {
|
|
11
9
|
this.redis = uri;
|
|
12
10
|
} else {
|
|
13
|
-
|
|
14
|
-
this.redis = new Redis(
|
|
11
|
+
options = Object.assign({}, typeof uri === 'string' ? { uri } : uri, options);
|
|
12
|
+
this.redis = new Redis(options.uri, options);
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
this.redis.on('error',
|
|
15
|
+
this.redis.on('error', error => this.emit('error', error));
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
_getNamespace() {
|
|
@@ -50,10 +48,8 @@ class KeyvRedis extends EventEmitter {
|
|
|
50
48
|
|
|
51
49
|
delete(key) {
|
|
52
50
|
return this.redis.del(key)
|
|
53
|
-
.then(items =>
|
|
54
|
-
|
|
55
|
-
.then(() => items > 0);
|
|
56
|
-
});
|
|
51
|
+
.then(items => this.redis.srem(this._getNamespace(), key)
|
|
52
|
+
.then(() => items > 0));
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
clear() {
|