C++中开源缓存的建议

use*_*694 11 c++ caching

我需要一个C++中的缓存库,它有点像Guave的 Loading Cache.

它应包括以下内容:

  • 非阻塞访问
  • 基于时间的驱逐
  • 基于规模的驱逐

我看过STL,Boost并搜索过,但我找不到任何有这个功能的东西.

Ale*_*lex 7

查看POCO.我相信它的缓存框架将满足您的需求.

ExpireLRUCache<int, string> cache(
                              1024,  // cacheSize
                              600000 // expiration (10 minutes)
);

cache.add( 1, "Cached string 1" );
cache.add( 10, "Cached string 10" );

Sleep( 601000 );

Shared_ptr<string> pVal = cache.get( 10 );
assert( pVal.isNull() ); // the element has expired
Run Code Online (Sandbox Code Playgroud)