wood burning stoves 2.0*
The moose likes Performance and the fly likes Need help in Implementing cache using hashmap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "Need help in Implementing cache using hashmap" Watch "Need help in Implementing cache using hashmap" New topic
Author

Need help in Implementing cache using hashmap

Sam Baheerathan
Greenhorn

Joined: Dec 31, 2010
Posts: 1
Hi,

I m developing employee management system using java and enterpriseDb. in this system i m planning to manage the employee details in a hash-map to reduce the disk I/O s. since this system will be used in several machines, i need to find a way to update the hash-map when ever a employee record is updated in the database. so that all the machines can have the latest updated records.
can anyone suggest me a way to implement this?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12756
    
    5
A google search for "java cache open source" found an enormous number of hits.

People have been fiddling with caching since Java 1.0

Bill
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

I would take Bill up on his suggestion. Developing a good cache is not trivial. How do you invalidate a cache ? When does a cache become stale ? When do you refresh the cache ? How do you deal with concurrency ? etc etc

There are many caching solutions that can sit between the caller and the DB. They should help.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Sandeep Murthy
Ranch Hand

Joined: Oct 05, 2005
Posts: 34
You can give "Hibernate" a try for starters.


SCJP 1.4
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7484
    
  18

Sam Baheerathan wrote:I m developing employee management system using java and enterpriseDb. in this system i m planning to manage the employee details in a hash-map to reduce the disk I/O s. since this system will be used in several machines, i need to find a way to update the hash-map when ever a employee record is updated in the database. so that all the machines can have the latest updated records.
can anyone suggest me a way to implement this?

Well, LinkedHashMap has some goodies that allow you to implement LRU (least-recently-used) caches quite easily. Specifically, have a look at the removeEldestEntry() method.

However, you haven't really given us enough information to give you informed advice.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help in Implementing cache using hashmap
 
Similar Threads
Sorting Maps
employee database system using Java technoloyges
Doubt in Hash Map and Hash Table
Application context cache of configuration data - any synchronization risk?
Real time update from database