I am working on a web-based medical application and need to create a small in-memory object cache. Here is my use-case.
We need to show list of requests submitted by people who need certain things (Blood, Kidney, etc.) and it's not going to be a huge list as in a given day request for blood or anything else will be a limited one. Please take into account that we do not want to use any caching API as it would be an overkill. The idea is to create a Map and place it in the ApplicationContext.
The moment a new request is being placed by any person, we will update that Map in the Application context and the moment the request expires, we will remove them from the Map. We need to look into the following points additionally.
- Need to set Max Element Limit.
- If Max Limit reached, we should removed entry which was added first.
- Take care of any Synchronized issues.
Please suggest what Data-structure should be used and what things to take care of while implementing this.