@depup/keyv-redis 1.3.4-depup.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/.travis.yml +12 -0
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/changes.json +14 -0
- package/package.json +76 -0
- package/src/index.js +69 -0
- package/test/test.js +9 -0
package/.travis.yml
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @depup/keyv-redis
|
|
2
|
+
|
|
3
|
+
> Dependency-bumped version of [keyv-redis](https://www.npmjs.com/package/keyv-redis)
|
|
4
|
+
|
|
5
|
+
Generated by [DepUp](https://github.com/depup/npm) -- all production
|
|
6
|
+
dependencies bumped to latest versions.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @depup/keyv-redis
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
| Field | Value |
|
|
15
|
+
|-------|-------|
|
|
16
|
+
| Original | [keyv-redis](https://www.npmjs.com/package/keyv-redis) @ 1.3.4 |
|
|
17
|
+
| Processed | 2026-03-17 |
|
|
18
|
+
| Smoke test | passed |
|
|
19
|
+
| Deps updated | 2 |
|
|
20
|
+
|
|
21
|
+
## Dependency Changes
|
|
22
|
+
|
|
23
|
+
| Dependency | From | To |
|
|
24
|
+
|------------|------|-----|
|
|
25
|
+
| pify | 3.0.0 | ^6.1.0 |
|
|
26
|
+
| redis | 2.8.0 | ^5.11.0 |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
Source: https://github.com/depup/npm | Original: https://www.npmjs.com/package/keyv-redis
|
|
31
|
+
|
|
32
|
+
License inherited from the original package.
|
package/changes.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@depup/keyv-redis",
|
|
3
|
+
"version": "1.3.4-depup.0",
|
|
4
|
+
"description": "[DepUp] Redis storage adapter for Keyv",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "xo && nyc ava",
|
|
8
|
+
"coverage": "nyc report --reporter=text-lcov | coveralls"
|
|
9
|
+
},
|
|
10
|
+
"xo": {
|
|
11
|
+
"extends": "xo-lukechilds"
|
|
12
|
+
},
|
|
13
|
+
"ava": {
|
|
14
|
+
"require": [
|
|
15
|
+
"requirable"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/lukechilds/keyv-redis.git"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"depup",
|
|
24
|
+
"dependency-bumped",
|
|
25
|
+
"updated-deps",
|
|
26
|
+
"keyv-redis",
|
|
27
|
+
"redis",
|
|
28
|
+
"keyv",
|
|
29
|
+
"storage",
|
|
30
|
+
"adapter",
|
|
31
|
+
"key",
|
|
32
|
+
"value",
|
|
33
|
+
"store",
|
|
34
|
+
"cache",
|
|
35
|
+
"ttl"
|
|
36
|
+
],
|
|
37
|
+
"author": "Luke Childs <lukechilds123@gmail.com> (http://lukechilds.co.uk)",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/lukechilds/keyv-redis/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/lukechilds/keyv-redis",
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"pify": "^6.1.0",
|
|
45
|
+
"redis": "^5.11.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"ava": "^0.20.0",
|
|
49
|
+
"coveralls": "^2.13.1",
|
|
50
|
+
"delay": "^2.0.0",
|
|
51
|
+
"eslint-config-xo-lukechilds": "^1.0.0",
|
|
52
|
+
"keyv": "*",
|
|
53
|
+
"keyv-test-suite": "^1.3.0",
|
|
54
|
+
"nyc": "^11.0.3",
|
|
55
|
+
"requirable": "^1.0.4",
|
|
56
|
+
"this": "^1.0.2",
|
|
57
|
+
"xo": "^0.19.0"
|
|
58
|
+
},
|
|
59
|
+
"depup": {
|
|
60
|
+
"changes": {
|
|
61
|
+
"pify": {
|
|
62
|
+
"from": "3.0.0",
|
|
63
|
+
"to": "^6.1.0"
|
|
64
|
+
},
|
|
65
|
+
"redis": {
|
|
66
|
+
"from": "2.8.0",
|
|
67
|
+
"to": "^5.11.0"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"depsUpdated": 2,
|
|
71
|
+
"originalPackage": "keyv-redis",
|
|
72
|
+
"originalVersion": "1.3.4",
|
|
73
|
+
"processedAt": "2026-03-17T22:57:07.790Z",
|
|
74
|
+
"smokeTest": "passed"
|
|
75
|
+
}
|
|
76
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const EventEmitter = require('events');
|
|
4
|
+
const redis = require('redis');
|
|
5
|
+
const pify = require('pify');
|
|
6
|
+
|
|
7
|
+
class KeyvRedis extends EventEmitter {
|
|
8
|
+
constructor(opts) {
|
|
9
|
+
super();
|
|
10
|
+
this.ttlSupport = true;
|
|
11
|
+
opts = opts || {};
|
|
12
|
+
if (opts.uri) {
|
|
13
|
+
opts = Object.assign({}, { url: opts.uri }, opts);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const client = redis.createClient(opts);
|
|
17
|
+
|
|
18
|
+
this.redis = ['get', 'set', 'sadd', 'del', 'srem', 'smembers'].reduce((obj, method) => {
|
|
19
|
+
obj[method] = pify(client[method].bind(client));
|
|
20
|
+
return obj;
|
|
21
|
+
}, {});
|
|
22
|
+
|
|
23
|
+
client.on('error', err => this.emit('error', err));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
_getNamespace() {
|
|
27
|
+
return `namespace:${this.namespace}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get(key) {
|
|
31
|
+
return this.redis.get(key)
|
|
32
|
+
.then(value => {
|
|
33
|
+
if (value === null) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return value;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
set(key, value, ttl) {
|
|
41
|
+
if (typeof value === 'undefined') {
|
|
42
|
+
return Promise.resolve(undefined);
|
|
43
|
+
}
|
|
44
|
+
return Promise.resolve()
|
|
45
|
+
.then(() => {
|
|
46
|
+
if (typeof ttl === 'number') {
|
|
47
|
+
return this.redis.set(key, value, 'PX', ttl);
|
|
48
|
+
}
|
|
49
|
+
return this.redis.set(key, value);
|
|
50
|
+
})
|
|
51
|
+
.then(() => this.redis.sadd(this._getNamespace(), key));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
delete(key) {
|
|
55
|
+
return this.redis.del(key)
|
|
56
|
+
.then(items => {
|
|
57
|
+
return this.redis.srem(this._getNamespace(), key)
|
|
58
|
+
.then(() => items > 0);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
clear() {
|
|
63
|
+
return this.redis.smembers(this._getNamespace())
|
|
64
|
+
.then(keys => this.redis.del.apply(null, keys.concat(this._getNamespace())))
|
|
65
|
+
.then(() => undefined);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
module.exports = KeyvRedis;
|
package/test/test.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import keyvTestSuite, { keyvOfficialTests } from 'keyv-test-suite';
|
|
3
|
+
import Keyv from 'keyv';
|
|
4
|
+
import KeyvRedis from 'this';
|
|
5
|
+
|
|
6
|
+
keyvOfficialTests(test, Keyv, 'redis://localhost', 'redis://foo');
|
|
7
|
+
|
|
8
|
+
const store = () => new KeyvRedis();
|
|
9
|
+
keyvTestSuite(test, Keyv, store);
|