I am writing a cache server in java that will cache image data (jpgs, pngs, tiff, etc.) in memory for quick access via http. Images are rendered by another service, which is an expensive operation, so I want to cache them on my cache server.
There are several reasons why I write this from scratch, so the answer I'm looking for is not [some smart software product]
Question How can I save a certain set of data objects in the main memory and make sure that the data is actually in the main memory when I need it and not push the disk to the virtual memory manager? That is, how can I do this in Java?
Additional Information: Objects can be referenced at any interval, for example. days or say years apart to be a little extreme :-)
EDIT : I found this SO post that asks: "Can you save objects in continuous memory?" βThis is not a question that I am asking about, although it could help if the objects were referenced all the time, I suppose.β And by the way, the answer to this question was βnoβ, except, obviously, for value types in arrays.
source share