|
Rumba C++ SDK
|
#include <Cache.h>
Public Member Functions | |
| std::shared_ptr< Value > | query (const Key &key) const |
| Query the cache with a key, returns nullptr if no entry is available. More... | |
| template<typename Func > | |
| std::shared_ptr< Value > | test_insert (const Key &key, Func craft) |
| Test and insert a cache value. More... | |
| std::shared_ptr< Value > Cache< Key, Value >::query | ( | const Key & | key | ) | const |
Query the cache with a key, returns nullptr if no entry is available.
| std::shared_ptr< Value > Cache< Key, Value >::test_insert | ( | const Key & | key, |
| Func | craft | ||
| ) |
Test and insert a cache value.
Test if the value is available in the cache for key, if not, call the craft function and store the result in the cache. In both cases, the method returns a cache value. The craft function prototype should be std::shared_ptr<Value> craft(). The craft function can return nullptr if it fails to build the value. In that case, next call to test_insert with the same key will try again to create a value with craft.