Search code examples
cachingwebspheredistributed-caching

How to make a cache entry in websphere not to expire


I have created a cache in the web sphere which will be shared by multiple applications and i wanted to make one entry in the created cache to not to expire. How can i make it ?

Thanks and Regards,

Sunny.


Solution

  • Are you deriving/using WebSpheres dyna-cache (DistributedObjectCache)? How are you creating your cache instance?

    The DistributedObjectCache (through it's DistributedMap parent) defines a "put" method overload that accepts a TTL for the individual cache entry. If you want to set the TTL for the entire cache, there is conversely a setTimeToLive(int) method in DistributedMap

    see http://publib.boulder.ibm.com/infocenter/dmndhelp/v6rxmx/index.jsp?topic=/com.ibm.wsps.602.javadoc.doc/doc/com/ibm/websphere/cache/DistributedMap.html

    Worth noting is that the TTL is not available as a configuration option in the cacheinstances.properties (or the admin console Resources/Cache Instances/Object cache instances), it has to be set programatically using setTimeToLive()