Reputation: 421
I have a project in which the data is readonly (no writes at all) and for each request a couple of thousand reads are performed and thus the bottleneck is getting the data from the database.
We're running tokumx on tmpfs (~12GB compressed database) and it still slow as serialization and socket communication take substantial time, so I wanted to "cache" one critical collection of 4.5m documents that are accessed through a single simple query. Eventually, we might migrate the whole database to some in-memory data store as it will make it even faster.
For now, I was thinking of just using a plain hashmap that is loaded at app startup, but I'm not sure is that the best way to do it :) Other options like Fongo are all made for unit testing and I'm not sure are they fast enough for this kind of situation
Any suggestions what to use for this problem?
Upvotes: 0
Views: 261
Reputation: 116
I suggest you to check the google library guava.
https://github.com/google/guava
With a cache you can load your data at the app startup but in case the data is not inside the cache, you can create a function to query your database.
Upvotes: 0