15 #ifndef IMPALA_UTIL_LRU_CACHE_H_
16 #define IMPALA_UTIL_LRU_CACHE_H_
18 #include <boost/optional.hpp>
19 #include <boost/thread.hpp>
20 #include <boost/thread/mutex.hpp>
21 #include <boost/unordered_map.hpp>
22 #include <glog/logging.h>
27 #include "gutil/macros.h"
60 template<
typename Key,
typename Value>
81 void Put(
const Key& k,
const Value& v);
89 bool Pop(
const Key& k, Value* out);
93 boost::lock_guard<SpinLock> g(
lock_);
118 typedef std::multimap<Key, typename ListType::iterator>
MapType;
136 #endif // IMPALA_UTIL_LRU_CACHE_H_
void Put(const Key &k, const Value &v)
size_t capacity() const
Returns the capacity of the cache.
bool Pop(const Key &k, Value *out)
void(* DeleterFn)(Value *)
DISALLOW_COPY_AND_ASSIGN(FifoMultimap)
static void DummyDeleter(Value *v)
size_t size()
Returns the total number of entries in the collection.
const size_t capacity_
Total capacity, cannot be changed at run-time.
~FifoMultimap()
Walk the list of elements and call the deleter function for each element.
SpinLock lock_
Protects access to cache_ and lru_list_.
FifoMultimap(size_t capacity, const DeleterFn &deleter=&FifoMultimap::DummyDeleter)
std::multimap< Key, typename ListType::iterator > MapType
std::pair< Key, Value > ValueType
std::list< ValueType > ListType