Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lms/djangoapps/courseware/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions openedx/core/djangoapps/content/block_structure/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ def _add_to_cache(self, serialized_data, bs_model):
"""
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:
Expand Down