Hi,
I have a java class that is being used by multiple people (from a UI).
In the class i have a static HashMap with the userKey as the map key and an arraylist with data pertaining to the user as the value. I am using this kind of like a cache. Because populating the list everytime the user logs in is a very expensive procedure.
Whenever a user logs in and modifies the data i am updating the list for that user in the map.
Now the issue is that I donot want to keep the entries in the HashMap forever. I need to clear the entries for users that have not been logged in for a while to be removed from the hashmap, but I do not want to clear the whole map.
I tried experimenting with WeakHashMap, but it didnt seem to work well with String keys.
Does anyone have any idea on what can be done in such a situation?
Any help is appreciated.
Thanks,
Aravind