Skip to content

Commit dfce041

Browse files
author
anthonyp97
committed
update comments
1 parent 49edae6 commit dfce041

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

cache_helper/decorators.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,21 @@ def wrapper(*args, **kwargs):
3636
)
3737
value = sentinel
3838

39+
# If there is an issue with our cache client deserializing the value (due to memory or some other issue),
40+
# we get a None response so log anytime this happens
3941
if value is None:
4042
logger.warning(
4143
'None cache value found for cache key: {}, function cache key: {}, value: {}'.format(
4244
cache_key, function_cache_key, value
4345
)
4446
)
4547

46-
# Need to check for None as well because the cache client sends a None response at times
4748
if value is sentinel or value is None:
4849
value = func(*args, **kwargs)
4950
# Try and set the key, value pair in the cache.
5051
# But if it fails on an error from the underlying
5152
# cache system, handle it.
5253
try:
53-
logger.info(
54-
'Setting cache key: {}, value: {} for function cache key: {}'.format(
55-
cache_key, value, function_cache_key
56-
)
57-
)
5854
cache.set(cache_key, value, timeout)
5955
except CacheSetError:
6056
logger.warning(
@@ -104,25 +100,21 @@ def wrapper(*args, **kwargs):
104100
)
105101
value = sentinel
106102

103+
# If there is an issue with our cache client deserializing the value (due to memory or some other issue),
104+
# we get a None response so log anytime this happens
107105
if value is None:
108106
logger.warning(
109107
'None cache value found for cache key: {}, function cache key: {}, value: {}'.format(
110108
cache_key, function_cache_key, value
111109
)
112110
)
113111

114-
# Need to check for None as well because the cache client sends a None response at times
115112
if value is sentinel or value is None:
116113
value = func(*args, **kwargs)
117114
# Try and set the key, value pair in the cache.
118115
# But if it fails on an error from the underlying
119116
# cache system, handle it.
120117
try:
121-
logger.info(
122-
'Setting cache key: {}, value: {} for function cache key: {}'.format(
123-
cache_key, value, function_cache_key
124-
)
125-
)
126118
cache.set(cache_key, value, timeout)
127119
except CacheSetError:
128120
logger.warning(
@@ -193,25 +185,21 @@ def __call__(self, *args, **kwargs):
193185
)
194186
value = sentinel
195187

188+
# If there is an issue with our cache client deserializing the value (due to memory or some other issue),
189+
# we get a None response so log anytime this happens
196190
if value is None:
197191
logger.warning(
198192
'None cache value found for cache key: {}, function cache key: {}, value: {}'.format(
199193
cache_key, function_cache_key, value
200194
)
201195
)
202196

203-
# Need to check for None as well because the cache client sends a None response at times
204197
if value is sentinel or value is None:
205198
value = self.func(*args, **kwargs)
206199
# Try and set the key, value pair in the cache.
207200
# But if it fails on an error from the underlying
208201
# cache system, handle it.
209202
try:
210-
logger.info(
211-
'Setting cache key: {}, value: {} for function cache key: {}'.format(
212-
cache_key, value, function_cache_key
213-
)
214-
)
215203
cache.set(cache_key, value, timeout)
216204
except CacheSetError:
217205
logger.warning(

0 commit comments

Comments
 (0)