@keyvhq/redis
Advanced tools
+22
| The MIT License (MIT) | ||
| Copyright © 2017 Luke Childs <lukechilds123@gmail.com> (https://lukechilds.co) | ||
| Copyright © 2021 Microlink <hello@microlink.io> (https://microlink.io) | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in | ||
| all copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| THE SOFTWARE. |
+3
-2
@@ -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" | ||
| } |
+2
-4
@@ -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 |
+9
-3
@@ -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%