2

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 it 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

Megatron
  • 2,871
  • 4
  • 40
  • 58

3 Answers3

2

Use boost to implement an LRU cache?

LRU implementation in production code

Community
  • 1
  • 1
Chris K
  • 11,996
  • 7
  • 37
  • 65
1

You mean like memcached or membase?

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
0

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

Piti Ongmongkolkul
  • 2,110
  • 21
  • 20