@keyvhq/offline
v2.1.5
Published
Adding offline capabilities for your keyv instance.
Downloads
16
Readme
@keyvhq/offline
Adds offline capabilities for your keyv instance.
Install
$ npm install @keyvhq/offline --save
Usage
All you need to do is to wrap your keyv instance:
const KeyvRedis = require('@keyvhq/redis')
const Keyv = require('@keyvhq/core')
const store = new KeyvRedis({
uri: 'redis://user:pass@localhost:6379',
maxRetriesPerRequest: 1,
emitErrors: false
})
const keyv = new Keyv({ store })
Using @keyvhq/offline
at the top level:
const KeyvOffline = require('@keyvhq/offline')
const keyv = keyvOffline(new Keyv({ store }))
Since now, if your store suffers network connectivity issues, your keyv set/get petitions will be temporarily bypassed, preventing your application to crash for that, being more resilient than the default keyv behavior.
As soon as the connection is re-established, it will be work back as expected.
In case you need, you can see omitted errors enabling debug doing DEBUG=@keyvhq/offline*
License
@keyvhq/memoize © Kiko Beats, released under the MIT License. Maintained by Microlink with help from contributors.
microlink.io · GitHub microlinkhq · X @microlinkhq