Home > front end >  Spring Data Gemfire: How to set TTL for entry using annotation?
Spring Data Gemfire: How to set TTL for entry using annotation?

Time:12-10

I am trying to set timeout for 30 days (i.e. 2592000 seconds) for entries in a region.

In, gfsh I was able to do create region --name=employee --type=REPLICATE --enable-statistics --entry-time-to-live-expiration=2592000. To confirm, do we use @TimeToLiveExpiration for entry not for region. I do not want the region to be deleted. If this is for entry then curious how can we set for region? Thanks.

@ReplicatedRegion(name = "employee") 
@EnableStatistics 
@TimeToLiveExpiration(timeout = "2592000", action = "DESTROY") // is this for region or entry ?? 
@Data
public class Employee {
   private String id; 
}

CodePudding user response:

Yes, both SDG's entity-level Expiration-based annotations, @TimeToLiveExpiration and @IdleTimeoutExpiration configure Region "entry" level expiration polices.

Technically, this is implemented as an CustomExpiry object (Javadoc) registered on the Region (e.g. "employees"). These annotations most definitely do NOT expire, or delete/remove the Region.

More information on configuring Apache Geode (GemFire) Expiration (policies) using SDG can be found here and here.

  • Related