distribucache-memory-store

RAM-backed Distribucache Store

Usage no npm install needed!

<script type="module">
  import distribucacheMemoryStore from 'https://cdn.skypack.dev/distribucache-memory-store';
</script>

README

Distribucache Memory Store Build Status NPM version

A memory (RAM) datastore for the Distribucache auto-repopulating cache.

Usage

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

var distribucache = require('distribucache'),
  memoryStore = require('distribucache-memory-store'),

  cacheClient = distribucache.createClient(memoryStore()),

  model = require('../model'), // for example
  cache,
  Service;

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

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

API

  • memoryStore()

License

MIT