Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Goldfish - the forgetful in-memory cache
// _, _,
// .' ( .-' /
// _/..._'. .' /
// .-'` ` '-./ _.'
// ( o) ;= <_
// '-.,\\__ __.-;`\ '.
// \) |`\ \) '. \
// \_/ jgs '-._\
// `
Goldfish({
populate: // fn(arg1, arg2, ..., cb)
expires: // (optional) Integer - miliseconds before a cache item is expired (default = Infinity)
remind: // (optional) Boolean - refresh expire time on fetch (default = false)
capacity: // (optional) Integer - max number of items to have in the cache (default = Infinity)
});
var redisClient = require('redis').createClient()
, Goldfish = require('goldfish')
, cache
;
cache = new Goldfish({
// the populate function will be run when a value does not yet exist in the cache
populate: function(key, cb) {
redisClient.get(key, cb);
},
capacity: 1000, // keep at max 1000 items in the cache
expires: 9001 // evict items that are older than 9001 ms
});
// get value from cache, because 'test' isn't populated, run the populate function
cache.get('test', function(err, result) {
if (err) return console.error(err);
return console.log(result);
});
// listen for any evictions
cache.on('evict', function(entry) {
console.log(entry.args); // Array - the args passed to populate resulting in this entry
console.log(evict.result); // Array - the results from populate
});
// clear the cache
cache.clear();
get#hit O(1)
get#miss O(1) + Populate()
clear O(n)
Complete disregard for the previous api. Don't blindly update.
Smaller, simpler api.
FAQs
Evented in-memory cache
The npm package goldfish receives a total of 0 weekly downloads. As such, goldfish popularity was classified as not popular.
We found that goldfish demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.