Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 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
80 changes: 54 additions & 26 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,22 @@ cc_library(
],
)

cc_library(
name = "simple_lru_cache_lib",
hdrs = [
"simple_lru_cache/simple_lru_cache.h",
"simple_lru_cache/simple_lru_cache_inl.h",
],
deps = [
"//external:abseil_flat_hash_map",
],
)

cc_test(
name = "check_audience_test",
timeout = "short",
srcs = [
"src/check_audience_test.cc",
"test/check_audience_test.cc",
],
linkopts = [
"-lm",
Expand All @@ -52,7 +63,7 @@ cc_test(
name = "jwt_test",
timeout = "short",
srcs = [
"src/jwt_test.cc",
"test/jwt_test.cc",
],
linkopts = [
"-lm",
Expand All @@ -69,8 +80,8 @@ cc_test(
name = "jwks_test",
timeout = "short",
srcs = [
"src/jwks_test.cc",
"src/test_common.h",
"test/jwks_test.cc",
"test/test_common.h",
],
linkopts = [
"-lm",
Expand All @@ -83,12 +94,29 @@ cc_test(
],
)

cc_test(
name = "simple_lru_cache_test",
timeout = "short",
srcs = [
"test/simple_lru_cache_test.cc",
],
linkopts = [
"-lm",
"-lpthread",
],
linkstatic = 1,
deps = [
":simple_lru_cache_lib",
"//external:googletest_main",
],
)

cc_test(
name = "verify_x509_test",
timeout = "short",
srcs = [
"src/test_common.h",
"src/verify_x509_test.cc",
"test/test_common.h",
"test/verify_x509_test.cc",
],
linkopts = [
"-lm",
Expand All @@ -105,8 +133,8 @@ cc_test(
name = "verify_audiences_test",
timeout = "short",
srcs = [
"src/test_common.h",
"src/verify_audiences_test.cc",
"test/test_common.h",
"test/verify_audiences_test.cc",
],
linkopts = [
"-lm",
Expand All @@ -123,8 +151,8 @@ cc_test(
name = "jwt_time_test",
timeout = "short",
srcs = [
"src/test_common.h",
"src/jwt_time_test.cc",
"test/test_common.h",
"test/jwt_time_test.cc",
],
linkopts = [
"-lm",
Expand All @@ -141,8 +169,8 @@ cc_test(
name = "verify_jwk_rsa_test",
timeout = "short",
srcs = [
"src/test_common.h",
"src/verify_jwk_rsa_test.cc",
"test/test_common.h",
"test/verify_jwk_rsa_test.cc",
],
linkopts = [
"-lm",
Expand All @@ -159,8 +187,8 @@ cc_test(
name = "verify_jwk_rsa_pss_test",
timeout = "short",
srcs = [
"src/test_common.h",
"src/verify_jwk_rsa_pss_test.cc",
"test/test_common.h",
"test/verify_jwk_rsa_pss_test.cc",
],
linkopts = [
"-lm",
Expand All @@ -177,8 +205,8 @@ cc_test(
name = "verify_jwk_ec_test",
timeout = "short",
srcs = [
"src/test_common.h",
"src/verify_jwk_ec_test.cc",
"test/test_common.h",
"test/verify_jwk_ec_test.cc",
],
linkopts = [
"-lm",
Expand All @@ -195,8 +223,8 @@ cc_test(
name = "verify_jwk_hmac_test",
timeout = "short",
srcs = [
"src/test_common.h",
"src/verify_jwk_hmac_test.cc",
"test/test_common.h",
"test/verify_jwk_hmac_test.cc",
],
linkopts = [
"-lm",
Expand All @@ -213,8 +241,8 @@ cc_test(
name = "verify_jwk_okp_test",
timeout = "short",
srcs = [
"src/test_common.h",
"src/verify_jwk_okp_test.cc",
"test/test_common.h",
"test/verify_jwk_okp_test.cc",
],
linkopts = [
"-lm",
Expand All @@ -231,8 +259,8 @@ cc_test(
name = "verify_pem_rsa_test",
timeout = "short",
srcs = [
"src/test_common.h",
"src/verify_pem_rsa_test.cc",
"test/test_common.h",
"test/verify_pem_rsa_test.cc",
],
linkopts = [
"-lm",
Expand All @@ -249,8 +277,8 @@ cc_test(
name = "verify_pem_ec_test",
timeout = "short",
srcs = [
"src/test_common.h",
"src/verify_pem_ec_test.cc",
"test/test_common.h",
"test/verify_pem_ec_test.cc",
],
linkopts = [
"-lm",
Expand All @@ -267,8 +295,8 @@ cc_test(
name = "verify_pem_okp_test",
timeout = "short",
srcs = [
"src/test_common.h",
"src/verify_pem_okp_test.cc",
"test/test_common.h",
"test/verify_pem_okp_test.cc",
],
linkopts = [
"-lm",
Expand Down
4 changes: 4 additions & 0 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def abseil_repositories(bind = True):
name = "abseil_flat_hash_set",
actual = "@com_google_absl//absl/container:flat_hash_set",
)
native.bind(
name = "abseil_flat_hash_map",
actual = "@com_google_absl//absl/container:flat_hash_map",
)
_cctz_repositories(bind)

CCTZ_COMMIT = "e19879df3a14791b7d483c359c4acd6b2a1cd96b"
Expand Down
45 changes: 45 additions & 0 deletions simple_lru_cache/simple_lru_cache.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

// For inclusion in .h files. The real class definition is in
// simple_lru_cache_inl.h.

#pragma once

#include <functional>

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

namespace google {
namespace jwt_verify {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please change namespace from jwt_verify to simple_lru_cache thanks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.


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 jwt_verify
} // namespace google
Loading