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 b开发者_Python百科efore it close the db have to be saved on the disk . i am using java and i want to use sql
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.
Take a look at SQLite and SqliteJDBC
Be aware though, that 2000rows is by no means large for a DB!
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).
精彩评论