0

I want to set TTL for every object in GemFire cache whenever I am putting that object into the cache. The TTL for an entry(object) in the cache can be different from another. Is it possible to do using Spring Data for Pivotal GemFire?

John Blum
  • 7,381
  • 1
  • 20
  • 30
Sunil Keshari
  • 99
  • 1
  • 2
  • 11

2 Answers2

0

This stackoverflow post has some examples of how to do this -

Spring Data GemFire: CustomExpiry Examples

Basically you can configure your own CustomExpiry for the region than can return a different ttl for each entry.

Dan Smith
  • 481
  • 2
  • 3
0

It is a bit unclear what you are asking.

As Dan mentioned in his answer to this post, you can set TTL for the entire Region, which will apply to all entries.

Alternatively, if you have really specific needs, you can set TTL per class type using the SDG Expiration annotation config as documented here:

https://docs.spring.io/spring-data/gemfire/docs/current/reference/html/#bootstrap:region:expiration:annotation

However, if you Region only stores a single type of object (e.g. Customer.class), then it is advisable to set TTL on the Region.

Although, if you have some complex object hierarchy, then the Expiration annotation support might be of value to your UC.

NOTE: The Expiration annotation support in SDG is actually implemented using a CustomExpiry implementation provided by SDG that introspect's the object's class type to determine the expiration policy (wether TTL or TTI) for that object based on the annotations.

John Blum
  • 7,381
  • 1
  • 20
  • 30