invalidate cache entries in Dynacache based on database entry

Hi experts

We are looking in to using websphere dynacache to cache a data structure that we build from the results of a db query. The data base tables are updated about every 5 minutes or so and we want to rerun the query and re-cache the data at about the same time the db is updated.  A small table exists that stores the timestamp of the last time an update was made.  What options are available to invalidate the cached data using this configuration?

 We were thinking we could poll that table every 30 seconds or so and see if the time stamp has changed since the last time the data was cached.  But I have not used dynacache before and from what I've read so far I don't know how to make it work the way we would like it to.  Any suggestions?

Thanks
Dave
LVL 4
NHBFighterAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
DarthModConnect With a Mentor Commented:
PAQed with points refunded (300)

DarthMod
Community Support Moderator
0
 
NHBFighterAuthor Commented:
An additional requirment is that we cannot spawn any threads in out code. All threads should be managed by websphere.
0
 
yuseungkimCommented:
So you need to configure Cache Invalidation with your code.

You can check "WebSphere Application Server V6 Scalability and Performance Handbook" from http://www.redbooks.ibm.com

Following is

The dynamic cache service provides event-based and time-based invalidation
techniques. WebSphere Application Server V6 offers access to programmatic
cache and invalidation techniques. Invalidation policies can be defined with XML
cache policy files. Invalidation policies allow triggering events to invalidate cache
entries without the need to write explicit code. More complex invalidation
scenarios may require code, which invokes the invalidation API.
Below Example shows the invalidation policy, which invalidates cache entries for
groups of objects using the same Account_UserID dependency ID. For example,
home servlet and all commands invoked by home servlet are invalidated when
the user logs out from the application.

Following Example show Invalidation policy defined in the logout command in cachespec.xml file
( please refer to the WebSphere InfoCenter for more detailed information about the cachespec.xml file. )

<cache-entry>
<class>command</class>
<sharing-policy>not-shared</sharing-policy>
<name>com.ibm.websphere.samples.trade.command.LogoutCommand</name>
<invalidation>Account_UserID
<component id="getUserID" type="method">
<required>true</required>
</component>
</invalidation>
<invalidation>Holdings_UserID1
<component id="getUserID" type="method">
<required>true</required>
</component>
</invalidation>
</cache-entry>

Cheers

Andy
0
 
NHBFighterAuthor Commented:
I think I understand that but for these to work something has to be triggered correct. IE a method in the command has to be called. What I need is to have something wake up every 30 seconds or so, see if the cache should be invalidated and then trigger the mehtod to invalidate the cache.

The idea we are working on now is to have two things in cache one is the data we want to cache and the other is a dummy object. The dummy object will be put into the cache and its TTL will be set to 30 seconds. Then we will put a listner on the experiation of that dummy object. When the listener is triggered the data base can be polled to see if the cache has expired. If so the update to the data we want to cache can be made. This process of the dummy object expiring every 30 seconds will be repeated indefinetly.

How does that idea sound?

Thanks
Dave
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.