Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions source/common/lru_cache/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
load(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we can just put this in source/common/common

"//bazel:envoy_build_system.bzl",
"envoy_cc_library",
"envoy_package",
)

licenses(["notice"]) # Apache 2

envoy_package()

envoy_cc_library(
name = "lru_cache_lib",
hdrs = [
"lru_cache.h",
"lru_cache_inl.h",
],
)
30 changes: 30 additions & 0 deletions source/common/lru_cache/lru_cache.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// For inclusion in .h files. The real class definition is in
// `lru_cache_inl.h`.

#pragma once

#include <functional>

#include "absl/container/flat_hash_map.h" // for hash<>

namespace Envoy {
namespace LruCache {

namespace internal {
template <typename T> struct SimpleLRUHash : public std::hash<T> {};
} // namespace internal

template <typename Key, typename Value, typename H = internal::SimpleLRUHash<Key>,
typename EQ = std::equal_to<Key>>
class SimpleLRUCache;

// Deleter is a functor that defines how to delete a Value*. That is, it
// contains a public method:
// operator() (Value* value)
// See example in the associated unittest.
template <typename Key, typename Value, typename Deleter, typename H = internal::SimpleLRUHash<Key>,
typename EQ = std::equal_to<Key>>
class SimpleLRUCacheWithDeleter;

} // namespace LruCache
} // namespace Envoy
Loading