You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by bing <bi...@buffalo.edu> on 2020/03/06 15:53:19 UTC
ignite 2.8.0 LRU eviction not work as expected.
Hello:
I run the server from 2.8.0 bin package with default-config.xml.
Here is my java client code:
Ignition.setClientMode(true);
final CacheConfiguration cfg = new CacheConfiguration("lru-cache");
cfg.setOnheapCacheEnabled(true);
final LruEvictionPolicyFactory<String, String> plc = new
LruEvictionPolicyFactory<String, String>(20,20,20);
cfg.setEvictionPolicyFactory(plc);
final Ignite ignite = Ignition.start();
cache = ignite.getOrCreateCache(cfg);
for(int i = 0; i < 10; i++) {
final String key = Integer.toString(i);
cache.put(key, key);
}
the output of cache.size(CachePeekMode.ONHEAP) is 1. and
cache.size(CachePeekMode.OFFHEAP) shows 10.
the output of cache.getEntry("0").getValue() will give "0", which I thought
it should be null, since I set LRU eviction.
In my user case, I want to use ignite as a pure in-memory cache. To enable
the LRU eviction, should I turn off the off-heap and could you please share
how to do it?
And since there is one item on the heap, may I know if there is a way to get
the cached item on the heap?
Moreover, I want to know if there is a way to set the max number of items
instead of the sizes in bytes.
Thanks!
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: ignite 2.8.0 LRU eviction not work as expected.
Posted by Mikhail <mi...@gmail.com>.
Hi Bing,
it works as expected:
https://www.gridgain.com/docs/latest/developers-guide/memory-architecture/eviction-policies#on-heap-cache-eviction
you set eviction only for on-heap, records will never be evicted from the
off-heap memory, but only from on -heap.
Please see my example:
https://gist.github.com/Mikhail1988/679665d7bad89b604d14b073de30ddb4
If you want to evict data from off-heap you need to use:
https://www.gridgain.com/docs/latest/developers-guide/memory-architecture/eviction-policies#off-heap-memory-eviction
Thanks,
Mike.
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/