-
1. Re: Can I customize my own eviction strategy?
galder.zamarreno Jan 31, 2012 7:49 AM (in response to forever-pi)1 of 1 people found this helpfulFirst of all, the eviction strategy is not currently pluggable.
Also, why do you need such eviction strategy? What is it that you're trying to achieve with it?
Eviction strategies are all about evicting stuff that's not in use and has not been used recently. LIRS is perfect for that. If you use other strategies, you might end up with unnecessary misses.
You might be evicting the smallest thing but if the smallest thing is the thing that's used the most, you're getting nothing out of caching.
-
2. Re: Can I customize my own eviction strategy?
forever-pi Feb 1, 2012 4:08 AM (in response to galder.zamarreno)You are right. Simply evicting the smallest thing from the memory is meaningless.
But it might make sense if I just want those big entries not to be evicted from the memory before there are some ones smaller than them, because the price to reload them back into memory is high. And I didn't find a EntryChosenForEvictionListner to be used for my purpose. That's what I am confused.
-
3. Re: Can I customize my own eviction strategy?
galder.zamarreno Feb 2, 2012 3:34 AM (in response to forever-pi)Right, I see what you mean now. So, the extension you're looking for is not available, nor Infinispan can provide information about the size of the object.
However, something you can do is have a cache listener and listen for @CacheEntriesEvicted, so when entries are evicted, you can get a map of key/value pairs that are evicted. You could then judge the size of the value and prefetch it in advance to avoid paying the price of reloading them when they're needed. That's assuming of course that the cost variable is time. If the cost variable is money, i.e. retrieving it from Amazon S3, then a I'd suggest tweaking the put() calls accordingly to pass a bigger lifespan and/or maxIdle time for bigger values so that they stay in memory for longer.