@keyvhq/redis
Advanced tools
Comparing version
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://github.com/microlinkhq/keyv", | ||
"version": "1.6.26", | ||
"version": "1.6.28", | ||
"main": "src/index.js", | ||
@@ -65,3 +65,4 @@ "author": { | ||
}, | ||
"types": "./src/index.d.ts" | ||
"types": "./src/index.d.ts", | ||
"gitHead": "69f95c41789d2a7fb83fbcc80e120e9f2a15274c" | ||
} |
@@ -19,5 +19,3 @@ # @keyvhq/redis [<img width="100" align="right" src="https://keyv.js.org/media/logo-sunset.svg" alt="keyv">](https://github.com/microlinkhq/keyv) | ||
const keyv = new Keyv({ | ||
store: new KeyvRedis('redis://user:pass@localhost:6379') | ||
}) | ||
const keyv = new Keyv({ store: new KeyvRedis('redis://user:pass@localhost:6379') }) | ||
@@ -33,3 +31,3 @@ keyv.on('error', handleConnectionError) | ||
const keyv = new Keyv({ | ||
const keyv = new Keyv({ | ||
store: new KeyvRedis('redis://user:pass@localhost:6379', { | ||
@@ -36,0 +34,0 @@ disable_resubscribing: true |
@@ -7,7 +7,11 @@ 'use strict' | ||
const normalizeOptions = (...args) => Object.assign({ emitErrors: true }, ...args) | ||
const normalizeOptions = (...args) => | ||
Object.assign({ emitErrors: true }, ...args) | ||
const normalizeArguments = (input, options) => { | ||
if (input instanceof Redis) return [input, normalizeOptions(options)] | ||
const { uri, ...opts } = Object.assign(typeof input === 'string' ? { uri: input } : input, options) | ||
const { uri, ...opts } = Object.assign( | ||
typeof input === 'string' ? { uri: input } : input, | ||
options | ||
) | ||
const normalizedOpts = normalizeOptions(opts) | ||
@@ -38,3 +42,5 @@ return [new Redis(uri, normalizedOpts), normalizedOpts] | ||
async set (key, value, ttl) { | ||
return typeof ttl === 'number' ? this.redis.set(key, value, 'PX', ttl) : this.redis.set(key, value) | ||
return typeof ttl === 'number' | ||
? this.redis.set(key, value, 'PX', ttl) | ||
: this.redis.set(key, value) | ||
} | ||
@@ -41,0 +47,0 @@ |
7674
19.98%5
25%99
6.45%54
-3.57%