• Post Reply Bookmark Topic Watch Topic
  • New Topic

Caching while data changes on a daily basis

 
Kuldeep Tewari
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The database our application is using, gets reloaded with a new set of data on a daily basis. I was wondering if using a cache in this scenario would be a good idea or not.
Is there any way I can detect the backend data change in my application somehow, so that I can reset application cache when the data changes in DB?
 
Ajay Saxena
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer lies in the question itself. You may want to build a database notification application that would appropriately notify your main application on any DB changes,thereby triggering a cache refresh.

Alternatively, your application would have to periodically poll the DB for changes continuously which is definitely going to hit the performance of your application,as the polling would consume some CPU cycles.

I'd prefer to go with the former method which is an implementation of asynchronous notification mechanism.
[ October 15, 2008: Message edited by: Ajay Saxena ]
 
Tim Holloway
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Database caching is at its best when the same data is likely to be needed within at most a few minutes of the last request. Holding all that data in the server for a full day at a time deprives other apps of resources.

You might consider what's known as a "materialized view", however. That's basically a way of marshalling what you need on the DBMS server for later retrieval.
 
Kuldeep Tewari
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replying Ajay,

But,

You may want to build a database notification application that would appropriately notify your main application on any DB changes,thereby triggering a cache refresh.


Would the "database notification application" not itself be polling DB to check for the updates?

Regards,
Kuldeep.
 
Kuldeep Tewari
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Tim, but I think I was not able to make you understand my question.

When I talk about caching data, I don't intend to cache it for the whole day. A particular set of the data will be
i) added to cache when I make a search(say a List of Customer value objects)
ii)updated in cache when I change something related to the cached dataset above(say, when I add a new customer).
and iii) removed from cache based on the cache eviction settings(say in 10 minutes)

My question is to be able to reset this cache whenever the data is being changed in the database not due to the my application user's actions but by a backend sql process that writes a new set of data(causing the cached data to be obsolete) to the same database tables I'm caching my data from.

Regards,

Kuldeep.
[ October 15, 2008: Message edited by: K Tewari ]
 
Ajay Saxena
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would the "database notification application" not itself be polling DB to check for the updates?


Well,certainly it would,but then you need not host it on the same machine your main app is running on.Polling at some point has to happen from the application end as the DB server doesn't have any client callback mechanism,in which case you could have some listener thread in the main app waiting on notifications from the DB server.
[ October 15, 2008: Message edited by: Ajay Saxena ]
 
Kuldeep Tewari
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, It seems that Oracle has some Data Change Notification capabilities.

http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_dcn.htm
http://www.oracle.com/technology/obe/11gr1_db/appdev/dcn/dcn.htm

I will see if it works for me.

Thanks for your help.

Regards.

Kuldeep.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!