Reputation:
I have an application server in Java which requires parsing a CSV file. Is there any way by which I could increase the performance, as the program requires parsing the CSV file for each new connection.
The CSV file is static, so I was thinking about caching it in the main memory.
Upvotes: 0
Views: 1259
Reputation: 533500
The file will be cached by the OS in memory for you if you read it re-read the file repeatedly. I suggest you cache the parsed data. You can check the modification data (and possibly the length) of the file and re-parse it only if it has changed.
Upvotes: 0
Reputation: 10949
Why cache the csv in memory? Cache the parsed result in memory. Don't know what you are parsing it to, but create a class that represents a record. Make that class immutable, and then cache in E.g. a List or Map if you want fast access to certain records.
Upvotes: 5