chore: fix cache content size calculation error (#36511)
Co-authored-by: M Umar Khan <umar.khan@A006-01609.local>
This commit is contained in:
committed by
GitHub
parent
0acc44fbcd
commit
b9556211be
@@ -795,10 +795,11 @@ def get_assignments_grades(user, course_id, cache_timeout):
|
||||
collected_block_structure = get_block_structure_manager(course_id).get_collected()
|
||||
|
||||
total_bytes_in_one_mb = 1024 * 1024
|
||||
data_size_in_mbs = round(len(pickle.dumps(collected_block_structure)) / total_bytes_in_one_mb, 2)
|
||||
if data_size_in_mbs < total_bytes_in_one_mb * 2:
|
||||
data_size_in_bytes = len(pickle.dumps(collected_block_structure))
|
||||
if data_size_in_bytes < total_bytes_in_one_mb * 2:
|
||||
cache.set(cache_key, collected_block_structure, cache_timeout)
|
||||
else:
|
||||
data_size_in_mbs = round(data_size_in_bytes / total_bytes_in_one_mb, 2)
|
||||
# .. custom_attribute_name: collected_block_structure_size_in_mbs
|
||||
# .. custom_attribute_description: contains the data chunk size in MBs. The size on which
|
||||
# the memcached client failed to store value in cache.
|
||||
|
||||
@@ -137,8 +137,9 @@ class BlockStructureStore:
|
||||
"""
|
||||
cache_key = self._encode_root_cache_key(bs_model)
|
||||
total_bytes_in_one_mb = 1024 * 1024
|
||||
data_size_in_mbs = round(len(serialized_data) / total_bytes_in_one_mb, 2)
|
||||
if data_size_in_mbs < total_bytes_in_one_mb * 2:
|
||||
data_size_in_bytes = len(serialized_data)
|
||||
data_size_in_mbs = round(data_size_in_bytes / total_bytes_in_one_mb, 2)
|
||||
if data_size_in_bytes < total_bytes_in_one_mb * 2:
|
||||
self._cache.set(cache_key, serialized_data, timeout=config.cache_timeout_in_seconds())
|
||||
logger.info("BlockStructure: Added to cache; %s, size: %.2fMB", bs_model, data_size_in_mbs)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user