dowjones / distribucache Goto Github PK
View Code? Open in Web Editor NEWDatastore-independent automatically-repopulating cache.
License: MIT License
Datastore-independent automatically-repopulating cache.
License: MIT License
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.
Also support a promise returned from populate
.
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
});
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?
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
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.