JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 745
  • Score
    100M100P100Q100749F
  • License MIT

Adding offline capabilities for your keyv instance.

Package Exports

  • @keyvhq/offline
  • @keyvhq/offline/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@keyvhq/offline) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@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