Simple C/C++ in-process cache similar to memcached
I need a simple (LRU) cache which should run in-process. I found memcached, which looks great but there does not seem to be an easy way to host it in-process. I don't need a distributed cache, just a simple key/value store and some开发者_StackOverflow社区 kind of LRU behaviour and some nice allocator to limit fragmentation, as the entry size varies a lot (few bytes -- few kilobytes.) There must be surely an existing implementation of such a thing? Should be C or C++.
I hate to answer this way, but it would be fairly simple to implement yourself.
Allocator. Use
mallocandfree. They do work, and they work well. This also makes it easier to interface with the rest of your program.Mutex -> hash table, tree, or trie. You can use a linked list to track LRU. Don't try to do fancy lockless stuff.
Should weigh less than a couple hundred lines, knock it out in a good solid day.
I've had success using commoncache but the project doesn't appear to have any activity and issues raised (with patches) by my colleague are still unaddressed...
加载中,请稍侯......
精彩评论