Goldfish
Goldfish - the forgetful in-memory cache
// _, _,// .' ( .-' /// _/..._'. .' /// .-'` ` '-./ _.'// ( o) ;= <_// '-.,\\__ __.-;`\ '.// \) |`\ \) '. \// \_/ jgs '-._\// `
Options
;
Example
Caching redis gets
var redisClient = Goldfish = cache ; cache = // the populate function will be run when a value does not yet exist in the cache { redisClient; } 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 functioncache; // listen for any evictionscache;// clear the cachecacheclear;
Performance
get#hit O(1)
get#miss O(1) + Populate()
clear O(n)
Changelog
0.1.0
Complete disregard for the previous api. Don't blindly update.
Smaller, simpler api.