Moved from GitHub ristretto/83
Posted by karlmcguire:
Moved from GitHub ristretto/83
Posted by karlmcguire:
karlmcguire commented :
@muesli Is there a way to set a hard memory/item limit on cache2go?
muesli commented :
I have been looking into that some years ago, but at least back then it wasn’t really possible to achieve that reliably. For example if you’d use cache2go to store pointers, there wasn’t a way to accurately calculate the underlying objects memory requirements.
I assume this is possible these days with the help of reflection?
karlmcguire commented :
I assume this is possible these days with the help of reflection?
Funny you should ask, it’s currently being discussed. Ristretto just leaves it up to the user to determine the size of items and provide it when calling Set (as the cost
parameter). We assume people storing pointers (slices, etc.) should have a reasonable guess of the underlying memory usage.
The reason I ask is for our hit ratio benchmarking we try to ensure that all implementations have the same “size” as to not skew the numbers.