Is there a way to examine an entry in a cache (org.infinispan.Cache
implementations) without affecting expiration policy?
Meaning, if I have configured maxIdle
, the results of the cache operation won't affect the time the entry is going to be evicted?
Something such as Ehcache
Cache.getQuiet(Object key)
.
If calling cache.containsKey
, does it have effect on idleness?
In regards to lifespan, accessing the entry from the cache doesn't affect this. Only maxIdle is affected by an access.
cache.containsKey
will affect max idle and it will be refreshed.
The only way to not update idleness is by iterating over the entries or accessing the entry through the DataContainer directly using peek (shown here).
DataContainer<K, V> container = cache.getAdvancedCache().getDataContainer();
InternalCacheEntry<K, V> entry = container.peek(key);
Note that this may not work properly with a distributed cache, since accessing the data container only reads local contents. Although it is also mentioned that max idle shouldn't be used in a clustered cache here, as it is not guaranteed to refresh idleness across cluster.