[Opensymphony-oscache] threading issues with NeedsRefreshException

kutzi <[email protected]> Wed, 13 Jul 2005 14:15:49 CDT
Newsgroups gmane.comp.java.open-symphony.os-cache
Message-ID <13499179.1121282201110.JavaMail.os-j2ee@opensymphony01.contegix.com>
> *sigh* you're a thick one aren't you? 

I don't think so ;)

> The initial post was an invitation to the many users
> of oscache to share how they may have tackled this
> issue since it seems it would be fairly common one.

I read your original post together with Lars' and yours follow ups. Together they sounded like a bug report/RFE against OSCache. Especially with Lars' comment to enter a new JIRA issue. Sorry, if I misread this.

> That the developers are "already aware of the fact"
> is obvious to anyone that's read the documentation, I
> wasn't trying to suggest that it was some new
> revelation, only trying to see how other folks worked
> around this design flaw.

I recognize that this is a design flaw but I still don't see what difference it would make in this use case, if it would not throw an exception:
With exception:

String myValue;
try {
  myValue = (String) admin.getFromCache(myKey, myRefreshPeriod);
} catch (NeedsRefreshException nre) {
  myValue=nre.getCacheContent();
  [start new thread to fetch data]
}
return myValue;

Without exception:

CacheEntry entry = admin.getFromCache(myKey, myRefreshPeriod);
if (entry.isExpired()) {
  [start new thread to fetch data]
}
return entry.getValue();

Not much code lines saved with the second one and not more understandable, either. You have to start a new thread in any case.

---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=4200&messageID=10548#10548