keyv-offline

1.0.3 • Public • Published

keyv-offline

Last version Coverage Status NPM Status

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

Package Sidebar

Install

npm i keyv-offline

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

6.94 kB

Total Files

5

Last publish

Collaborators

  • kikobeats