Socket
Socket
Sign inDemoInstall

@keyv/redis

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keyv/redis - npm Package Compare versions

Comparing version 2.2.3 to 2.3.0

src/index.d.ts

122

package.json
{
"name": "@keyv/redis",
"version": "2.2.3",
"description": "Redis storage adapter for Keyv",
"main": "src/index.js",
"scripts": {
"test": "xo && nyc ava",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov",
"clean": "rm -rf node_modules && rm -rf .nyc_output && rm -rf coverage.lcov"
},
"xo": {
"extends": "xo-lukechilds",
"rules": {
"unicorn/prefer-module": 0
}
},
"ava": {
"require": [
"requirable"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/jaredwray/keyv.git"
},
"keywords": [
"redis",
"keyv",
"storage",
"adapter",
"key",
"value",
"store",
"cache",
"ttl"
],
"author": "Jared Wray <me@jaredwray.com> (http://jaredwray.com)",
"license": "MIT",
"bugs": {
"url": "https://github.com/jaredwray/keyv/issues"
},
"homepage": "https://github.com/jaredwray/keyv",
"dependencies": {
"ioredis": "^4.28.5"
},
"devDependencies": {
"@keyv/test-suite": "*",
"ava": "^3.15.0",
"delay": "^5.0.0",
"eslint-config-xo-lukechilds": "^1.0.1",
"keyv": "*",
"nyc": "^15.1.0",
"requirable": "^1.0.5",
"this": "^1.1.0",
"xo": "^0.47.0"
}
"name": "@keyv/redis",
"version": "2.3.0",
"description": "Redis storage adapter for Keyv",
"main": "src/index.js",
"scripts": {
"test": "xo && nyc ava",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov",
"clean": "rm -rf node_modules && rm -rf .nyc_output && rm -rf coverage.lcov"
},
"xo": {
"extends": "xo-lukechilds",
"rules": {
"unicorn/prefer-module": 0
}
},
"ava": {
"require": [
"requirable"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/jaredwray/keyv.git"
},
"keywords": [
"redis",
"keyv",
"storage",
"adapter",
"key",
"value",
"store",
"cache",
"ttl"
],
"author": "Jared Wray <me@jaredwray.com> (http://jaredwray.com)",
"license": "MIT",
"bugs": {
"url": "https://github.com/jaredwray/keyv/issues"
},
"homepage": "https://github.com/jaredwray/keyv",
"dependencies": {
"ioredis": "^5.0.3"
},
"devDependencies": {
"@keyv/test-suite": "*",
"ava": "^4.1.0",
"delay": "^5.0.0",
"eslint-config-xo-lukechilds": "^1.0.1",
"keyv": "*",
"nyc": "^15.1.0",
"requirable": "^1.0.5",
"this": "^1.1.0",
"tsd": "^0.20.0",
"typescript": "^4.6.3",
"xo": "^0.48.0"
},
"tsd" : {
"directory" : "test"
},
"types": "./src/index.d.ts",
"engines": {
"node": ">= 12"
},
"files": [
"src"
]
}

@@ -0,1 +1,2 @@

// @ts-ignore
const EventEmitter = require('events');

@@ -8,2 +9,4 @@ const Redis = require('ioredis');

this.ttlSupport = true;
this.opts = {};
this.opts.dialect = 'redis';

@@ -13,3 +16,3 @@ if (uri instanceof Redis || uri instanceof Redis.Cluster) {

} else {
options = Object.assign({}, typeof uri === 'string' ? { uri } : uri, options);
options = { ...(typeof uri === 'string' ? { uri } : uri), ...options };
this.redis = new Redis(options.uri, options);

@@ -36,2 +39,7 @@ }

getMany(keys) {
return this.redis.mget(keys)
.then(rows => rows.every(row => row === null) ? [] : rows);
}
set(key, value, ttl) {

@@ -59,9 +67,44 @@ if (typeof value === 'undefined') {

deleteMany(key) {
return this.delete(key);
}
clear() {
return this.redis.smembers(this._getNamespace())
.then(keys => this.redis.del(keys.concat(this._getNamespace())))
.then(keys => this.redis.del([...keys, ...this._getNamespace()]))
.then(() => undefined);
}
async * iterator(namespace) {
const scan = this.redis.scan.bind(this.redis);
const get = this.redis.mget.bind(this.redis);
async function * iterate(curs, pattern) {
const [cursor, keys] = await scan(curs, 'MATCH', pattern);
if (keys.length === 0) {
return;
}
const values = await get(keys);
for (const i in keys) {
if (Object.prototype.hasOwnProperty.call(keys, i)) {
const key = keys[i];
const value = values[i];
yield [key, value];
}
}
if (cursor !== '0') {
yield * iterate(cursor, pattern);
}
}
yield * iterate(0, `${namespace ? namespace + ':' : ''}*`);
}
has(key) {
return this.redis.exists(key)
.then(value => value !== 0);
}
}
module.exports = KeyvRedis;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc