1.0.3 • Published 3 years ago
keyv-offline v1.0.3
keyv-offline
Adding offline capabilities for your keyv instance.
Install
$ npm install keyv-offline --save
Usage
All you need to do is to wrap your keyv instance:
const KeyvRedis = require('@keyvhq/redis')
const keyv = new KeyvRedis({
uri: 'redis://user:pass@localhost:6379',
maxRetriesPerRequest: 1,
emitErrors: false
})
Using keyv-offline
at the top level:
const KeyvRedis = require('@keyvhq/redis')
const keyvOffline = require('keyv-offline')
const keyv = keyvOffline(new KeyvRedis({
uri: 'redis://user:pass@localhost:6379',
maxRetriesPerRequest: 1,
emitErrors: false
}))
That's all!
In the next database downtime, 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=keyv-offline*
License
keyv-offline © Kiko Beats, released under the MIT License. Authored and maintained by Kiko Beats with help from contributors.
kikobeats.com · GitHub Kiko Beats · Twitter @Kikobeats