#ifndef QUICHE_QUIC_CORE_QUIC_LRU_CACHE_H_
#define QUICHE_QUIC_CORE_QUIC_LRU_CACHE_H_
#include <memory>
#include "quiche/quic/platform/api/quic_export.h"
#include "quiche/quic/platform/api/quic_flag_utils.h"
#include "quiche/quic/platform/api/quic_flags.h"
#include "quiche/quic/platform/api/quic_logging.h"
#include "quiche/common/quiche_linked_hash_map.h"
namespace quic {
template <class K, class V, class Hash = std::hash<K>,
class Eq = std::equal_to<K>>
class QUICHE_EXPORT QuicLRUCache {
private:
using HashMapType =
typename quiche::QuicheLinkedHashMap<K, std::unique_ptr<V>, Hash, Eq>;
public:
using iterator = typename HashMapType::iterator;
using const_iterator = typename HashMapType::const_iterator;
using reverse_iterator = typename HashMapType::reverse_iterator;
using const_reverse_iterator = typename HashMapType::const_reverse_iterator;
explicit QuicLRUCache(size_t capacity) : … { … }
QuicLRUCache(const QuicLRUCache&) = delete;
QuicLRUCache& operator=(const QuicLRUCache&) = delete;
iterator begin() { … }
const_iterator begin() const { … }
iterator end() { … }
const_iterator end() const { … }
reverse_iterator rbegin() { … }
const_reverse_iterator rbegin() const { … }
reverse_iterator rend() { … }
const_reverse_iterator rend() const { … }
void Insert(const K& key, std::unique_ptr<V> value) { … }
iterator Lookup(const K& key) { … }
iterator Erase(iterator iter) { … }
void Clear() { … }
size_t MaxSize() const { … }
size_t Size() const { … }
private:
quiche::QuicheLinkedHashMap<K, std::unique_ptr<V>, Hash, Eq> cache_;
const size_t capacity_;
};
}
#endif