RE: [Opensymphony-oscache] OsCache Refresh

"Chris Miller" <[email protected]> Thu, 14 Apr 2005 18:36:40 +0000
Newsgroups gmane.comp.java.open-symphony.os-cache
Message-ID <[email protected]>
As I pointed out, there is no background thread in OSCache - all activity 
happens as a direct result of calls to the API. So if you want to update a 
cache entry you'll need to tell OSCache to do so. You'll need to run your 
own thread that pushes data into the cache as you need to (ie every half 
hour) and just specify an infinite expiry time when requesting that object 
from your other thread(s).

The difference between the refresh period and a cron expression is that the 
refresh period specifies the maximum allowable age of a cache entry, whilst 
a cron expression specifies specific expiry times, regardless of how old an 
entry is. Eg imagine caching an object at 10:29am. With a refresh period of 
30 minutes that entry would expire at 10:59am. With a cron expression of 
"0,30 * * * *" that entry would expire at 10:30am.

>From: Kavita <[email protected]>
>Reply-To: [email protected]
>To: [email protected]
>Subject: [Opensymphony-oscache] OsCache Refresh
>Date: Thu, 14 Apr 2005 13:17:49 CDT
>
>Thanks, but this raises another question.
>
>How does a REFRESH INTERVAL differ from a CRON EXPRESSION.
>
>How can cron expression it be used to do an AUTOMATIC refresh?
>
>e.g.: @ 10 AM, i pulled some data from database, created a object (List) & 
>stored it in the cache - using GeneralCacheAdministrator.putInCache method.
>
>Whenever users ask for this data, its fetched from the cache - using 
>GeneralCacheAdministrator.getFromCache() method.
>
>What I need is - Whether or not user asks for data, the data should get 
>refreshed in the cache - for this I may set the refresh period of 30 mins. 
>How can a cron expression help me with this?
>
>No matter what, to get data from cache, I have to call the 
>GeneralCacheAdministrator.getFromCache() method with keyName & either 
>refreshInterval &/or cron expression.
>
>The functioanlity I am looking for is something like a "Background Thread" 
>which checks if the data is stale & refreshes it. Is this readily available 
>in OSCache?