I start using the LRU cache package.
One of the option params is max - The maximum size of the cache.
I don't understand what the meaning of this parameter? Is it the size of the cache or the size of each file in the cache? is it in Bytes? KB? When the cache size is go to this max size, what happen?
It is the maximum total size of the cache. And it is in user-defined units. You must define it as per your object.
The length
function calculates the size of each object. You can make it return in floats as well if you want. For actual use cases, you would want to make length function return byte sizes taken up by the object. If you use buffer/string you can return its length. But that is for you to implement.
This is how the cache works:
When the cache reaches this limit. Adding any more values removes another object(s). More accurately this happens when there isn't enough space available to add that object in the cache. LRU is a replacement policy to decide which object(s) get evicted. It removes the objects which has been accessed the last.