My java applciation is a console application.I am reading a lot of read only data and keeping it under a List called flatFileList.
List flatFileList = readLotofDataFromFile(fileName);
Now this flatFileList is used in almost all parts of the code. I do not want to read the datafile again. So I created a singleton class , and a getInstance()
I use this getInstance() method anywhere I need to get the flatFileList object.My question is this,can this singleton pattern be called as a cache mechanism ? because I am not re reading the data again from the flatfile.
Sure, that’s exactly what a cache is for: parts of (or all) data is read into a usually non-persistent memory close to the process that requires the data to improve access speed.