我需要一个C++中的缓存库,它有点像Guave的 Loading Cache.
它应包括以下内容:
我看过STL,Boost并搜索过,但我找不到任何有这个功能的东西.
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)