Skip to content

Commit 1b7f65a

Browse files
committed
Simplify slightly
1 parent d8363e4 commit 1b7f65a

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/stac_auth_proxy/utils/filters.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,25 @@ class MemoryCache:
6060
def get(self, ctx: Any) -> Any:
6161
"""Get a value from the cache."""
6262
key = self.get_value_by_path(ctx, self.key)
63-
if key in self.cache:
64-
result, timestamp = self.cache[key]
65-
age = time() - timestamp
66-
if age <= self.ttl:
67-
logger.debug(
68-
"%r in cache, returning cached result",
69-
key if len(str(key)) < 10 else f"{str(key)[:9]}...",
70-
)
71-
return result
63+
if key not in self.cache:
7264
logger.debug(
73-
"%r in cache, but expired.",
65+
"%r not in cache, calling function",
7466
key if len(str(key)) < 10 else f"{key[:9]}...",
7567
)
76-
else:
68+
return None
69+
70+
result, timestamp = self.cache[key]
71+
age = time() - timestamp
72+
if age <= self.ttl:
7773
logger.debug(
78-
"%r not in cache, calling function",
79-
key if len(str(key)) < 10 else f"{key[:9]}...",
74+
"%r in cache, returning cached result",
75+
key if len(str(key)) < 10 else f"{str(key)[:9]}...",
8076
)
81-
return None
77+
return result
78+
logger.debug(
79+
"%r in cache, but expired.",
80+
key if len(str(key)) < 10 else f"{key[:9]}...",
81+
)
8282

8383
def set(self, ctx: Any, value: Any):
8484
"""Set a value in the cache."""

0 commit comments

Comments
 (0)