Solved

invalidate cache entries in Dynacache based on database entry

Posted on 2006-06-27
6
1,828 Views
Last Modified: 2013-12-10
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
0
Comment
Question by:NHBFighter
  • 2
6 Comments
 
LVL 4

Author Comment

by:NHBFighter
Comment Utility
An additional requirment is that we cannot spawn any threads in out code. All threads should be managed by websphere.
0
 
LVL 3

Expert Comment

by:yuseungkim
Comment Utility
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
 
LVL 4

Author Comment

by:NHBFighter
Comment Utility
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
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
Comment Utility
PAQed with points refunded (300)

DarthMod
Community Support Moderator
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This exercise is about for the following scenario: Dmgr and One node with 2 application server. Each application server contains it owns application. Application server name as follows server1 contains app1 server2 contains app1 Prereq…
Upgrading Tomcat – There are a couple of methods to upgrade Tomcat is to use The Apache Installer is to download and unzip and run the services.bat remove|install Tomcat6 Because of the App that we are working with, we can only use Tomcat 6.…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now