@keyvhq/offline

2.1.5 • Public • Published

@keyvhq/offline keyv

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

Package Sidebar

Install

npm i @keyvhq/offline

Homepage

keyv.js.org

Weekly Downloads

16

Version

2.1.5

License

MIT

Unpacked Size

4.91 kB

Total Files

4

Last publish

Collaborators

  • kikobeats
  • jytesh