Hello,
I'm looking for clarification on how to set cache max size. In this example:
var LRU = require("lru-cache")
, options = { max: 500
, length: function (n) { return n * 2 }
, dispose: function (key, n) { n.close() }
, maxAge: 1000 * 60 * 60 }
, cache = LRU(options)
, otherCache = LRU(50) // sets just the max sizeWhat value does 'length' function operate on? Is n related to key or value stored in cache?
I store documents of an average size of 1.5 kB in cache. Key is an MD5 hash (constant length).
Since I know average document size can I return 1 as length function output, and treat max as document count?
I.e. if max = 500 then it's an indicator of 500 documents, each of size 1.5 kB (750 kB total)?
Thanks,
M