@@ -30,9 +30,9 @@ def _get_function_cache_keys(func_name: str, func_signature: Signature, args: tu
30
30
"""
31
31
bound_arguments = func_signature .bind (* args , ** kwargs )
32
32
bound_arguments .apply_defaults ()
33
- function_cache_key = utils .get_function_cache_key (func_name , bound_arguments .args , bound_arguments .kwargs )
34
- hashed_function_cache_key = utils .get_hashed_cache_key (function_cache_key )
35
- return hashed_function_cache_key , function_cache_key
33
+ cache_key_string = utils .get_function_cache_key (func_name , bound_arguments .args , bound_arguments .kwargs )
34
+ cache_key_hashed = utils .get_hashed_cache_key (cache_key_string )
35
+ return cache_key_hashed , cache_key_string
36
36
37
37
38
38
def cached (timeout ):
@@ -42,16 +42,16 @@ def _cached(func):
42
42
43
43
@wraps (func )
44
44
def wrapper (* args , ** kwargs ):
45
- cache_key , function_cache_key = _get_function_cache_keys (func_name , func_signature , args , kwargs )
45
+ cache_key_hashed , cache_key_string = _get_function_cache_keys (func_name , func_signature , args , kwargs )
46
46
47
47
# We need to determine whether the object exists in the cache, and since we may have stored a literal value
48
48
# None, use a sentinel object as the default
49
49
sentinel = object ()
50
50
try :
51
- value = cache .get (cache_key , sentinel )
51
+ value = cache .get (cache_key_hashed , sentinel )
52
52
except Exception :
53
53
logger .warning (
54
- f'Error retrieving value from Cache for Key: { function_cache_key } ' ,
54
+ f'Error retrieving value from Cache for Key: { cache_key_string } ' ,
55
55
exc_info = True ,
56
56
)
57
57
value = sentinel
@@ -61,7 +61,7 @@ def wrapper(*args, **kwargs):
61
61
if value is None :
62
62
logger .warning (
63
63
'None cache value found for cache key: {}, function cache key: {}, value: {}' .format (
64
- cache_key , function_cache_key , value
64
+ cache_key_hashed , cache_key_string , value
65
65
)
66
66
)
67
67
@@ -71,10 +71,10 @@ def wrapper(*args, **kwargs):
71
71
# But if it fails on an error from the underlying
72
72
# cache system, handle it.
73
73
try :
74
- cache .set (cache_key , value , timeout )
74
+ cache .set (cache_key_hashed , value , timeout )
75
75
except CacheSetError :
76
76
logger .warning (
77
- f'Error saving value to Cache for Key: { function_cache_key } ' ,
77
+ f'Error saving value to Cache for Key: { cache_key_string } ' ,
78
78
exc_info = True ,
79
79
)
80
80
@@ -106,17 +106,17 @@ def _cached(func):
106
106
def wrapper (* args , ** kwargs ):
107
107
# replace the first arg for caching purposes because it will be the class itself
108
108
cls_adjusted_args = (None , * args [1 :])
109
- cache_key , function_cache_key = _get_function_cache_keys (
109
+ cache_key_hashed , cache_key_string = _get_function_cache_keys (
110
110
func_name , func_signature , cls_adjusted_args , kwargs
111
111
)
112
112
# We need to determine whether the object exists in the cache, and since we may have stored a literal value
113
113
# None, use a sentinel object as the default
114
114
sentinel = object ()
115
115
try :
116
- value = cache .get (cache_key , sentinel )
116
+ value = cache .get (cache_key_hashed , sentinel )
117
117
except Exception :
118
118
logger .warning (
119
- f'Error retrieving value from Cache for Key: { function_cache_key } ' ,
119
+ f'Error retrieving value from Cache for Key: { cache_key_string } ' ,
120
120
exc_info = True ,
121
121
)
122
122
value = sentinel
@@ -126,7 +126,7 @@ def wrapper(*args, **kwargs):
126
126
if value is None :
127
127
logger .warning (
128
128
'None cache value found for cache key: {}, function cache key: {}, value: {}' .format (
129
- cache_key , function_cache_key , value
129
+ cache_key_hashed , cache_key_string , value
130
130
)
131
131
)
132
132
@@ -136,10 +136,10 @@ def wrapper(*args, **kwargs):
136
136
# But if it fails on an error from the underlying
137
137
# cache system, handle it.
138
138
try :
139
- cache .set (cache_key , value , timeout )
139
+ cache .set (cache_key_hashed , value , timeout )
140
140
except CacheSetError :
141
141
logger .warning (
142
- f'Error saving value to Cache for Key: { function_cache_key } ' ,
142
+ f'Error saving value to Cache for Key: { cache_key_string } ' ,
143
143
exc_info = True ,
144
144
)
145
145
@@ -195,16 +195,16 @@ def __get__(self, obj, objtype):
195
195
return fn
196
196
197
197
def __call__ (self , * args , ** kwargs ):
198
- cache_key , function_cache_key = self .create_cache_key (* args , ** kwargs )
198
+ cache_key_hashed , cache_key_string = self .create_cache_key (* args , ** kwargs )
199
199
200
200
# We need to determine whether the object exists in the cache, and since we may have stored a literal value
201
201
# None, use a sentinel object as the default
202
202
sentinel = object ()
203
203
try :
204
- value = cache .get (cache_key , sentinel )
204
+ value = cache .get (cache_key_hashed , sentinel )
205
205
except Exception :
206
206
logger .warning (
207
- f'Error retrieving value from Cache for Key: { function_cache_key } ' ,
207
+ f'Error retrieving value from Cache for Key: { cache_key_string } ' ,
208
208
exc_info = True ,
209
209
)
210
210
value = sentinel
@@ -214,7 +214,7 @@ def __call__(self, *args, **kwargs):
214
214
if value is None :
215
215
logger .warning (
216
216
'None cache value found for cache key: {}, function cache key: {}, value: {}' .format (
217
- cache_key , function_cache_key , value
217
+ cache_key_hashed , cache_key_string , value
218
218
)
219
219
)
220
220
@@ -224,10 +224,10 @@ def __call__(self, *args, **kwargs):
224
224
# But if it fails on an error from the underlying
225
225
# cache system, handle it.
226
226
try :
227
- cache .set (cache_key , value , timeout )
227
+ cache .set (cache_key_hashed , value , timeout )
228
228
except CacheSetError :
229
229
logger .warning (
230
- f'Error saving value to Cache for Key: { function_cache_key } ' ,
230
+ f'Error saving value to Cache for Key: { cache_key_string } ' ,
231
231
exc_info = True ,
232
232
)
233
233
@@ -241,14 +241,14 @@ def _invalidate(self, *args, **kwargs):
241
241
:param kwargs: The kwargs passed into the original function.
242
242
:rtype: None
243
243
"""
244
- cache_key , _ = self .create_cache_key (* args , ** kwargs )
245
- cache .delete (cache_key )
244
+ cache_key_hashed , _ = self .create_cache_key (* args , ** kwargs )
245
+ cache .delete (cache_key_hashed )
246
246
247
247
def create_cache_key (self , * args , ** kwargs ):
248
248
# Need to include the first arg (self) in the cache key
249
249
func_name = utils .get_function_name (self .func )
250
250
func_signature = signature (self .func )
251
- cache_key , function_cache_key = _get_function_cache_keys (func_name , func_signature , args , kwargs )
252
- return cache_key , function_cache_key
251
+ cache_key_hashed , cache_key_string = _get_function_cache_keys (func_name , func_signature , args , kwargs )
252
+ return cache_key_hashed , cache_key_string
253
253
254
254
return wrapper
0 commit comments