-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: [AXIMST-682] add caching for side navigation endpoint #2518
feat: [AXIMST-682] add caching for side navigation endpoint #2518
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, quality checks require a fix
cms/djangoapps/contentstore/utils.py
Outdated
Drop the course sidebar blocks cache for the given course. | ||
""" | ||
cache_key_prefix = f"course_sidebar_blocks_{course_id}" | ||
all_cache_keys = cache.keys('*') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only concern here is to retrieve all keys here. There can be many keys to load.
Could you check some potential improvements like:
def drop_course_sidebar_blocks_cache(course_id: str):
cache_key_prefix = f"course_sidebar_blocks_{course_id}"
for key in cache.iter_keys(f"{cache_key_prefix}*"):
cache.delete(key)
or
def drop_course_sidebar_blocks_cache(course_id: str):
cache_key_prefix = f"course_sidebar_blocks_{course_id}"
cache.delete_many(f"course_sidebar_blocks_{course_id}{key}" for key in cache.iter_keys(f"{cache_key_prefix}*"))
I assume that we have memcached
and not redis
and there can be limitations. Also I am glad to hear you thoughts on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It really is better that way, thank you)
I tried using the prefix with '*' in all
method, but it didn't work that way.
for i, child in enumerate(block['children']): | ||
block['children'][i] = self.mark_complete_recursive(child) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for i, child in enumerate(block['children']): | |
block['children'][i] = self.mark_complete_recursive(child) | |
block['children'] = [self.mark_complete_recursive(child) for child in block['children']] |
is it better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, thanks. Refactored
83c486f
to
f33e171
Compare
* feat: [AXIMST-682] add caching for side navigation endpoint * feat: [AXIMST-682] drop side navigation cache on course publishing * style: [AXIMST-682] fix code style * feat: [AXIMST-682] add waffle flag to enable/disable sidebar caching * feat: [AXIMST-682] exclude discussion blocks from completion calculation * refactor: [AXIMST-682] improvements after review
* feat: [AXIMST-682] add caching for side navigation endpoint * feat: [AXIMST-682] drop side navigation cache on course publishing * style: [AXIMST-682] fix code style * feat: [AXIMST-682] add waffle flag to enable/disable sidebar caching * feat: [AXIMST-682] exclude discussion blocks from completion calculation * refactor: [AXIMST-682] improvements after review
* feat: [AXIMST-682] add caching for side navigation endpoint * feat: [AXIMST-682] drop side navigation cache on course publishing * style: [AXIMST-682] fix code style * feat: [AXIMST-682] add waffle flag to enable/disable sidebar caching * feat: [AXIMST-682] exclude discussion blocks from completion calculation * refactor: [AXIMST-682] improvements after review
* feat: [AXIMST-682] add caching for side navigation endpoint * feat: [AXIMST-682] drop side navigation cache on course publishing * style: [AXIMST-682] fix code style * feat: [AXIMST-682] add waffle flag to enable/disable sidebar caching * feat: [AXIMST-682] exclude discussion blocks from completion calculation * refactor: [AXIMST-682] improvements after review
* feat: [AXIMST-682] add caching for side navigation endpoint * feat: [AXIMST-682] drop side navigation cache on course publishing * style: [AXIMST-682] fix code style * feat: [AXIMST-682] add waffle flag to enable/disable sidebar caching * feat: [AXIMST-682] exclude discussion blocks from completion calculation * refactor: [AXIMST-682] improvements after review
* feat: [AXIMST-682] add caching for side navigation endpoint * feat: [AXIMST-682] drop side navigation cache on course publishing * style: [AXIMST-682] fix code style * feat: [AXIMST-682] add waffle flag to enable/disable sidebar caching * feat: [AXIMST-682] exclude discussion blocks from completion calculation * refactor: [AXIMST-682] improvements after review
feat: AXIMST-682 add caching for side navigation endpoint