Radi
Radi

Reputation: 6584

cached data base

in my project i need a tow tables each of it has about 2000 row , i want my application to be speed so my db should load into memory (cached) when the app start and before it close the db have to be saved on the disk . i am using java and i want to use sql

Upvotes: 2

Views: 116

Answers (3)

Ricardo Marimon
Ricardo Marimon

Reputation: 10687

If the database that you need in memory is mostly read only I would keep a cache in memory but whenever there is a write I would propagate that change directly to the database. This way if the application breaks down you have the current state already in the database.

This should be very simple to write using a Map (or a series of Maps if you need multiple keys to access the data).

Upvotes: 1

Rob Heiser
Rob Heiser

Reputation: 2862

For Java, take a look at H2. It has in-memory databases, is written in Java and should provide the performance you need. Derby or HSQLDB are other Java alternatives.

Upvotes: 2

lexu
lexu

Reputation: 8849

Take a look at SQLite and SqliteJDBC

Be aware though, that 2000rows is by no means large for a DB!

Upvotes: 1

Related Questions