ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kevin <kevin.c...@leonardo.com>
Subject Re: Is there a hook on cache entry expiry?
Date Wed, 30 Dec 2015 17:37:40 GMT
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.

Mime
View raw message