Giter VIP home page Giter VIP logo

distribucache-redis-store's Introduction

Distribucache Redis Store Build Status NPM version

A Redis datastore for the Distribucache auto-repopulating cache.

Usage

Here's what a simple service using Distribucache with Redis may look like:

import distribucache from 'distribucache';
import redisStore from 'distribucache-redis-store';
import model from '../model'; // for example

const store = redisStore({host: 'localhost', port: 6379});
const cacheClient = distribucache.createClient(store);

const cache = cacheClient.create('my:values', {
  staleIn: '10 sec',
  populateIn: '5 sec',
  pausePopulateIn: '1 min',
  populate(key, cb) {
    model.get(key, cb);
  }
});

class Service {
  get(key, cb) {
    cache.get(key, cb);
  }
}

API

  • redisStore(config)

Possible config values below.

{String} [config.namespace]
{Boolean} [config.isPreconfigured] defaults to false (see note below)
{Object} [config.options] see ioredis options

isPreconfigured is used to determine whether the store needs to set-up keyspace notifications, which are used to support the populateIn feature in a way that multiple Distribucache clients would not conflict with each other while automatically populating the cache. Disable this to avoid a warning if you're running Redis in an environment where CONFIG is not available. One such environment is AWS. There you will need to set the notify-keyspace-events property to Kx manually through the AWS Management Console.

In addition to the config above, all of the options defined in ioredis are allowed to configure the Redis client.

License

MIT

distribucache-redis-store's People

Contributors

adamrights avatar mkonikov avatar nemtsov avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

distribucache-redis-store's Issues

Support ElastiCache Redis failover

The store should handle the case when another master is selected in ElastiCache, while connecting to the Primary Endpoint.

One way to do that is to detect the READONLY error and re-connect.

Feature: fallback on memory when redis fails

  1. Detect issues with the redis connection
  2. If there's an issue, call populate once, store the data in memory and keep attempting to reconnect
  3. Once the connection is recovered, delete all of the data stored in memory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.