Skip to content
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

Conversation

NiedielnitsevIvan
Copy link

feat: AXIMST-682 add caching for side navigation endpoint

@NiedielnitsevIvan NiedielnitsevIvan changed the title feat: [AXIMST-682](https://youtrack.raccoongang.com/issue/AXIMST-682) add caching for side navigation endpoint feat: [AXIMST-682] add caching for side navigation endpoint Mar 21, 2024
@NiedielnitsevIvan NiedielnitsevIvan self-assigned this Mar 21, 2024
Copy link
Collaborator

@monteri monteri left a 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

Drop the course sidebar blocks cache for the given course.
"""
cache_key_prefix = f"course_sidebar_blocks_{course_id}"
all_cache_keys = cache.keys('*')
Copy link
Collaborator

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

Copy link
Author

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.

Comment on lines 510 to 511
for i, child in enumerate(block['children']):
block['children'][i] = self.mark_complete_recursive(child)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, thanks. Refactored

@NiedielnitsevIvan NiedielnitsevIvan force-pushed the Ivan_Niedielnitsev/AXIMST-682/feature/Implement-caching-for-side-navigation-endpoint branch from 83c486f to f33e171 Compare March 21, 2024 14:58
@monteri monteri merged commit 29182fa into ts-develop Mar 22, 2024
41 of 43 checks passed
monteri pushed a commit that referenced this pull request Mar 27, 2024
* 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
ruzniaievdm pushed a commit that referenced this pull request Mar 28, 2024
* 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
ruzniaievdm pushed a commit that referenced this pull request Apr 4, 2024
* 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
monteri pushed a commit that referenced this pull request Apr 10, 2024
* 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
GlugovGrGlib pushed a commit that referenced this pull request Apr 12, 2024
* 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
monteri pushed a commit that referenced this pull request Apr 17, 2024
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants