Hi,
I am working on this code..where a datacache is implemented as a HashMap. The Hashmap has a key and an string arraylist <> associated with it. There is a refresh time period and data expiry time associated with data in the hashmap. In certain scenerios, some data of certain Type in the data cache needs to be refreshed and not all.
The way refresh is working currently, it makes a query to the database for the dataType which needs to be refershed and adds that data to the cache. Since the key for HashMap needs to be unique it overwriites any data associated with a key which already exists and adds any new data.
However, a bug with this implemention is it does not remove any data from the cache which does not exsist in the database anymore.
Nothing gets removed from the datacache until expiry period is reached. But it is not necessary refresh will always be called after expiry of data.
If someone can please suggest a way I can improve the refresh method so that it removes any Key/data from the cache which is not in the database anymore?
I do not want to clear the cache completely before refresh is called.
Any suggestions?
Thanks.