For a few projects I'm working on I need a persistent key value store (something akin to memcache). It would ideally run as a server; it needs to be really efficient. I'm aware that memcachedb exists, but I'd like to have a go at writing it myself as there's going to be a lot of custom functionality that I'll need to include later on. I'll probably be writing this in C++ (or possibly C or Java if there is a good reason to do so).
Should I be looking at database implementation (B-trees, indexes, etc.) or is that unnecessary for this kind of job? What would be a good way of storing most of the content on disk, but being able to access it quickly, utilising memory for caching?
Thanks.