Oracle coherence caching, specifying expiry timeout while adding the object into cache

StackOverflow https://stackoverflow.com/questions/21877682

  •  13-10-2022
  •  | 
  •  

سؤال

I am using oracle coherence caching.

For configuring expiry, there is a parameter called 'expiry-delay' to configure the expiry in xml file.

I would like to know if it is possible to pass the expiry duration while adding the object into the cache.

Appreciate any help on this.

هل كانت مفيدة؟

المحلول

try to set TTL value when you put new item to the cache

Object put(Object oKey,
       Object oValue,
       long cMillis)

CacheMap JavaDoc

نصائح أخرى

You can invoke the method put(Object oKey, Object oValue, long cMillis) on the NamedCache you hold. When calling this method, your entry will expire exactly after cMillis it is committed to the cache (and committed to the DB if you have persistency). By this way, Coherence will ignore the default value set in the scheme definition. If you wanna use anyway the default value, you can use CacheMap.EXPIRY_DEFAULT as value.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top