user471059
user471059

Reputation:

Cache a CSV file on Java application server

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

Answers (2)

Peter Lawrey
Peter Lawrey

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

Kaj
Kaj

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

Related Questions