AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
ConcurrentCache.h
1
6#pragma once
7
8#include <aws/core/utils/DateTime.h>
9#include <aws/core/utils/Cache.h>
10#include <aws/core/utils/threading/ReaderWriterLock.h>
11
12namespace Aws
13{
14 namespace Utils
15 {
16 template <typename TKey, typename TValue>
18 {
19 public:
20 explicit ConcurrentCache(size_t size = 1000) : m_cache(size) { }
21
22 bool Get(const TKey& key, TValue& value) const
23 {
25 return m_cache.Get(key, value);
26 }
27
28 template<typename UValue>
29 void Put(const TKey& key, UValue&& val, std::chrono::milliseconds duration)
30 {
32 m_cache.Put(key, std::forward<UValue>(val), duration);
33 }
34
35 template<typename UValue>
36 void Put(TKey&& key, UValue&& val, std::chrono::milliseconds duration)
37 {
39 m_cache.Put(std::move(key), std::forward<UValue>(val), duration);
40 }
41
42 using TransformFunction = std::function<typename Aws::Utils::Cache<TKey, TValue>::Value(const TKey &,
44
47 m_cache.Transform(function);
48 }
49
50 using FilterFunction = std::function<bool(const TKey &,
52
53 void Filter(FilterFunction function) {
55 m_cache.Filter(function);
56 }
57
58 private:
61 };
62 }
63}
void Filter(FilterFunction function)
std::function< typename Aws::Utils::Cache< TKey, TValue >::Value(const TKey &, const typename Aws::Utils::Cache< TKey, TValue >::Value &)> TransformFunction
std::function< bool(const TKey &, const typename Aws::Utils::Cache< TKey, TValue >::Value &)> FilterFunction
bool Get(const TKey &key, TValue &value) const
void Put(TKey &&key, UValue &&val, std::chrono::milliseconds duration)
ConcurrentCache(size_t size=1000)
void Transform(TransformFunction function)
void Put(const TKey &key, UValue &&val, std::chrono::milliseconds duration)