twitter / storehaus

Storehaus is a library that makes it easy to work with asynchronous key value stores
Apache License 2.0
465 stars 92 forks source link

MutableTTLCache does not evict on time #317

Open acjay opened 8 years ago

acjay commented 8 years ago

I've been experiencing unexpected behavior with MutableTTLCache not actually evicting expired keys. It seems it only checks for expiration every 1000 puts. I suppose this probably makes sense under certain circumstances, but it isn't documented or configurable.

acjay commented 8 years ago

Actually, I'm realizing that the line linked to above isn't exactly the source of my problem. My key's aren't being evicted on time, but it doesn't have to do with the put behavior. I'm making reads after the configured expiration time, but I'm not seeing the memoized function being invoked.

Upon further investigation, the problem is that calling the memoized function performs its lookup though hit, which does no expiration checking, unlike get. Is this an oversight? Why does hit exist? Interestingly, hit unconditionally attempts a put, but as mentioned above, pruning only happens every thousandth time.

pankajroark commented 8 years ago

+1 to hit being documented. I looked around and couldn't figure out what it's meant for either. @sritchie any idea?