What is a fast and efficient way to implement the server-side component for an autocomplete feature in an html input box?
I am writing a service to autocomplete use
If you can't physically load all the data into RAM then you're going to have to deal with having some on disk.
What DB are you using?
For example Oracle has an option where you can keep the entire table in memory, and perform your queries against that.
MySQL also claims to have some in-memory capabilities, but I don't know much about MySQL.
You can then do away with your java based cache, or you could use the cache for the most popular/recent searches.
Obviously when you run out of RAM then some of the data will be on disk when you query for it, but depending on the load on the system, this will only be an issue for the first keypress, not the subsequent ones, as the row will be in memory after that.
If the disk seek is slowing you down, then you could investigate using SSD drives to speed up your reads.