File tree Expand file tree Collapse file tree 2 files changed +4
-7
lines changed
src/stac_auth_proxy/utils Expand file tree Collapse file tree 2 files changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -15,9 +15,6 @@ class MemoryCache:
1515 cache : dict [tuple [Any ], tuple [Any , float ]] = field (default_factory = dict )
1616 _last_pruned : float = field (default_factory = time )
1717
18- class Expired (Exception ):
19- """Exception raised when a cache entry has expired."""
20-
2118 def __getitem__ (self , key : Any ) -> Any :
2219 """Get a value from the cache if it is not expired."""
2320 if key not in self .cache :
@@ -30,7 +27,7 @@ def __getitem__(self, key: Any) -> Any:
3027 msg = f"{ self ._key_str (key )} in cache, but expired."
3128 del self .cache [key ]
3229 logger .debug (msg )
33- raise self . Expired (f"{ key } expired" )
30+ raise KeyError (f"{ key } expired" )
3431
3532 logger .debug (f"{ self ._key_str (key )} in cache, returning cached result." )
3633 return result
@@ -45,14 +42,14 @@ def __contains__(self, key: Any) -> bool:
4542 try :
4643 self [key ]
4744 return True
48- except ( KeyError , self . Expired ) :
45+ except KeyError :
4946 return False
5047
5148 def get (self , key : Any ) -> Any :
5249 """Get a value from the cache."""
5350 try :
5451 return self [key ]
55- except ( KeyError , self . Expired ) :
52+ except KeyError :
5653 return None
5754
5855 def _prune (self ):
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ def test_memory_cache_expiration():
4343 mock_time .return_value = 1006.0 # 6 seconds later
4444
4545 # Test expired key
46- with pytest .raises (MemoryCache . Expired ):
46+ with pytest .raises (KeyError ):
4747 cache [key ]
4848
4949 # Test contains after expiration
You can’t perform that action at this time.
0 commit comments