rockyroad
rockyroad

Reputation: 2957

Clear cache in Apache Ignite every n seconds

How do we empty the cache every n seconds (so that we can run queries on the data that has come in for the n second window - batch window querying)? I could only find FIFO and LRU based eviction policies in the ignite code where the eviction policy is based on the cache entry getting added or modified.

I understand we can have a sliding window using CreatedExpiryPolicy

cfg.setExpiryPolicyFactory(FactoryBuilder.factoryOf(new CreatedExpiryPolicy(new Duration(SECONDS, 5))));

But I don't think this will help me maintain batch windows. Neither will FIFO or LruEvictionPolicy.

I need some eviction policy which is based on some static time window (every 5 seconds for example). Will I have to write my own implementation?

Upvotes: 1

Views: 799

Answers (1)

Evgenii Zhuravlev
Evgenii Zhuravlev

Reputation: 3007

Well, it's possible to change ExpiryPolicy for each added entry with

IgniteCache.withExpiryPolicy

and calculate remaining time every time, but it will be too big overhead - each entry will have their own EvictionPolicy.

I would recommend to schedule job that will clear the cache using cron based scheduling:

Upvotes: 2

Related Questions