The cache is limited to this data size. Setting large values is potentially O(n), where n is the number of objects which must be removed to make room for the new value. Setting a value that is too large for the cache is O(n) and will result in an error being throw. For performance, you should protect against this in your code.
Generated using TypeDoc
An in-memory LRU cache, implemented using a doubly-linked list.
import { MemCacheLRUBinning, toGibibytes } from "mega-cache"; const maxDataSize = toGibibytes(1); let cache = new MemCacheLRU( maxDataSize // defaults to 150MiB ); cache.set("key", Buffer.from("value")); cache.get("key").toString(); //=> "value" cache.get(cache.tail).toString() //=> "value" cache.pop() //=> "key" cache.pop() //=> undefined