Now I see what you're trying to achieve.
When you're executing these lines of the code
for (int i = 0; i < 100_000; i++) {
cache2.put(i, i);
each cache entry will have expiration time that can be calculated as ET
= current_time + policy_expire_time.
It's worth to mention that 'current_time' of each entry will differ on
some delta cause entries are inserted one by one into the cache and thus
will be evicted in an order they were inserted.
Transactions don't have any affect on the value of expiration time of an
entry.
I would recommend you using cache2.putAll(allEntries) instead in order
to minimize the delta, mentioned above, as much as possible.
This should let you to support almost 'grouped' expiration of entries.
--
Denis
On 12/30/2015 8:37 PM, kevin wrote:
I thought of a test to put together but it didn't work.
CacheConfiguration<Integer, Integer> cfg = new
CacheConfiguration<>();
cfg.setName("test1");
cfg.setCacheMode(CacheMode.PARTITIONED);
cfg.setRebalanceMode(CacheRebalanceMode.SYNC);
cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cfg.setBackups(1);
IgniteCache<Integer, Integer> cache1 = ignite.getOrCreateCache(cfg);
IgniteCache<Integer, Integer> cache2 = cache1.withExpiryPolicy(
new AccessedExpiryPolicy(new Duration(TimeUnit.SECONDS,
2)));
try (Transaction tx = ignite.transactions().txStart()) {
for (int i = 0; i < 100_000; i++) {
cache2.put(i, i);
}
tx.commit();
}
int lastSize = -1;
while (true) {
int size = cache2.size();
// int size = cache2.localSize();
// int size = cache2.query(new ScanQuery<>()).getAll().size();
if (size != lastSize) {
System.out.println(size);
lastSize = size;
}
}
I would've expected to see
100000
0
But I got
100000
99846
99431
98927
etc...
I also tried a few ways of accessing the cache as in the commented code.
--
View this message in context:
http://apache-ignite-users.70518.x6.nabble.com/Is-there-a-hook-on-cache-entry-expiry-tp2344p2360.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.