开发者

C++ memory cache data structure

I was wondering if there is an equivalent of the MemoryCache class from .net in C++? (http://msdn.microsoft.com/en-us/library/system.runtime.caching.memorycache.aspx)

I'm loading audio files/images frequently in my program and I'd like to avoid reloading audio/video if I've recently used i开发者_JAVA技巧t by keeping it in a memory cache. I realize I could use a map or something similar, but I was wondering if there was a data structure that'd be better suited to this sort of thing? Additionalyl if I used a map, I'd have to continually check when to expire something from the map and remove it

Does boost include something like this? I have that available already.

Thanks in advance


Use boost to implement an LRU cache?

LRU implementation in production code


You mean like memcached or membase?


I have that in my gist... just a light packaging of std::queue and std::unordered_map (queue is used for expiration). Queue based expiration may or may not suit your purpose though.

https://gist.github.com/2413834

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜