| 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: 12268
|
|
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
|
Java Resources at www.wbrogden.com
|
 |
Deepak Bala
Bartender
Joined: Feb 24, 2006
Posts: 6588
|
|
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 - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
|
 |
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: 4749
|
|
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?
|
 |
 |
|
|
subject: Need help in Implementing cache using hashmap
|
|
|