freecache
freecache copied to clipboard
Why we couldn't set Key-Value larger than 1/1024 of cache size?
Is it possible to make this stuff configurable?
It's limited by the data structure, large values don't fit in the data structure.
Out of curiosity — I get why it can't be larger than 1/256 (separate segments), but where does the extra factor of 4 come from? Is it primarily just to avoid wasting space if your entries take up too big a fraction of a segment, or is there some other reason that that factor must be of 4?
@glasser If an entry takes too big a fraction of a segment, it will be evicted when a new entry is written, the LRU algorithm does not work.
@coocood Hi, also experiencing this issue, trying to set the value to something thats big enough! Can you kindly advise what unit of measurement this variable is in. Seems like I experience this error with almost every byte object i try to store unless I follow your documentation on the README. Which is great, but I don't know which numbers represent what!
@mmacheerpuppy The code is at this line https://github.com/coocood/freecache/blob/master/segment.go#L85 It's not configurable.
@coocood Sorry to add confusion, I mean these values cache := freecache.NewCache( 100 * 1024 * 1024), not sure why we do 100 * 1024 * 1024!
@coocood Sorry to add confusion, I mean these values
cache := freecache.NewCache( 100 * 1024 * 1024), not sure why we do 100 * 1024 * 1024!
I'm sorry for misunderstanding your question.
The unit is byte, 1024 * 1024 means MB, I think it is the default unit for memory size if not specified.
@coocood Right okay that makes total sense to me now, could I open a PR to get that in the README? (See PRs!)
@mmacheerpuppy Sure!