Giter VIP home page Giter VIP logo

distribucache's People

Contributors

adamrights avatar jamesmanning avatar nemtsov avatar

Stargazers

 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

distribucache's Issues

Add ability to return raw values from the datastore (sans marshalling)

As a client configuring a new store,
I want to force distribucache to not marshall values,
In order to optimize for memory and cpu.

This is useful when you need to store a buffer or string and not an object (e.g., caching the html of the page). It will avoid the Buffer (Redis) -> String (Redis) -> Object (Distribucache) -> String (Express) -> Buffer (Http) conversion that currently happens with the Redis store when storing the page html in cache.

Possible configuration:

cache = cacheClient.create('page:v1', {
  useRawValues: true
});

populateIn does not restart after pausePopulateIn triggers

Repro:

var distribucache = require('distribucache'),
  memoryStore = require('distribucache-memory-store'),
  store = memoryStore(),
  logEvents = require('distribucache-console-logger'),
  cacheClient = distribucache.createClient(store),
  cache;

cache = cacheClient.create('randomness', {
  populateIn: '5 sec',
  pausePopulateIn: '10 sec',
  populate: function (key, cb) {
    setTimeout(function () {
      var value = Math.round(Math.random() * 1000);
      console.log('[client] populating with:', value);
      cb(null, value);
    }, 250);
  }
});

logEvents(cache);

function doIt() {
  var t = Date.now();
  cache.get('k8', function (err, value) {
    if (err) return console.error('[client] ', err);
    console.log('[client] got `%j` (type: %s) in %dms',
      value, typeof value, Date.now() - t);
  });
}

console.log('--------------- GET ------------------')
doIt();

setTimeout(function () { 
  console.log('------------- POPULATE -------------')
}, 5000);

setTimeout(function () { 
  console.log('---------- PAUSING NOW ----------')
}, 10000);

setTimeout(function () {
  doIt();
  setInterval(doIt, 5000);
}, 16000);

Result:

--------------- GET ------------------
2016-02-09T19:45:32.991Z get:before - k8
2016-02-09T19:45:32.993Z get:after - k8,2
2016-02-09T19:45:32.994Z get:miss - k8
2016-02-09T19:45:32.994Z populate:before - k8
[client] populating with: 561
2016-02-09T19:45:33.246Z set:before - k8,561
2016-02-09T19:45:33.248Z set:after - k8,561,2
2016-02-09T19:45:33.248Z populate:after - k8,254
[client] got `561` (type: number) in 258ms
---------- POPULATE ----------
2016-02-09T19:45:38.254Z populateIn:before - k8
2016-02-09T19:45:38.256Z populate:before - k8
[client] populating with: 327
2016-02-09T19:45:38.510Z set:before - k8,327
2016-02-09T19:45:38.511Z set:after - k8,327,1
2016-02-09T19:45:38.511Z populate:after - k8,255
2016-02-09T19:45:38.511Z populateIn:after - k8,257
---------- PAUSING NOW ----------
2016-02-09T19:45:43.515Z populateIn:before - k8
2016-02-09T19:45:43.515Z populateIn:pause - k8
2016-02-09T19:45:43.516Z populateIn:after - k8,1
2016-02-09T19:45:48.995Z get:before - k8
2016-02-09T19:45:48.996Z get:after - k8,1
2016-02-09T19:45:48.996Z get:hit - k8
[client] got `327` (type: number) in 1ms
2016-02-09T19:45:53.997Z get:before - k8
2016-02-09T19:45:53.997Z get:after - k8,0
2016-02-09T19:45:53.997Z get:hit - k8
[client] got `327` (type: number) in 0ms
2016-02-09T19:45:58.998Z get:before - k8
2016-02-09T19:45:58.998Z get:after - k8,0
2016-02-09T19:45:58.998Z get:hit - k8
[client] got `327` (type: number) in 0ms
2016-02-09T19:46:04.000Z get:before - k8
2016-02-09T19:46:04.000Z get:after - k8,0
2016-02-09T19:46:04.001Z get:hit - k8
[client] got `327` (type: number) in 1ms
2016-02-09T19:46:09.007Z get:before - k8
2016-02-09T19:46:09.007Z get:after - k8,0
2016-02-09T19:46:09.007Z get:hit - k8
[client] got `327` (type: number) in 0ms

Issue:
The [client] got 327 does not change after pausePopulateIn.

Add support for populate() with their own ETag

As a client using the populate(),
I want the method to accept a new ETag, provide the ETag of the previous value,
and I want to be able to tell populate that the previous value has not changed,
So that I would not have to waste bandwidth when the data-provider is capable of working with ETags.

unhandled error event log message

distribucache error from an unhandled error event:
PopulateError: failed to populate key "centralbanks"; cause: timed out after 30000ms
at null._onTimeout (/home/servo/node_modules/distribucache/lib/util.js:37:8)
at Timer.listOnTimeout as ontimeout

Why is this reporting an error is unhandled?

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.