× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Fri, 01 Jul 2011 09:25:44 -0500, James Horn wrote:

Hi Pete

The caching seems a little scary to me. I assume you don't do it if the
method gets data from a file (or whatever) which could change between
the calls.

Jim

Of course not, if the data could potentially change between calls. Those
types of methods are actions, which don't own the data, and either don't
go in the service program, or sequentially process requests that change
the request keys. Otherwise, yes, I do, especially when I have to
retrieve the data from the database, since those methods tend to be the
most resource intensive.

I cache the returned value and the parameters. When any of the parameters
change, I clear the return value and refresh it. That makes it
unnecessary to retrieve the same data multiple times, and is entirely
transparent to the user of the data. It just makes things run faster.

Typically, the same data is needed by multiple methods in my "expert"
service programs, so it can be requested with impunity whenever it's
needed. Of course, in my environment, the database is relatively static
during the day, and I only cache the most recent request. We have heavy
batch workloads that run at night.

I also implement a clean-up method, that sets a global switch and
executes each method, so that the method itself can clean up its data and
release any resources as appropriate. For good measure, I also tend to
code the requester programs to run in named activation groups that can be
destroyed when the requester ends.

I've had no issues at all with corrupted or stale result data. The
granularity of the cached data is either very fine, or the data itself
can be assumed to be static at processing time.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.