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

Button to clear cache (in dropdown) #1801

Merged
merged 7 commits into from
Feb 19, 2023
Merged

Button to clear cache (in dropdown) #1801

merged 7 commits into from
Feb 19, 2023

Conversation

KesterTan
Copy link
Contributor

@KesterTan KesterTan commented Feb 6, 2023

Description

Added a button to clear expired cache (cache cleanup).

On desktop

Screenshot 2023-02-06 at 4 09 56 PM

On mobile

Screenshot 2023-02-06 at 4 12 01 PM

After button is pressed

Screenshot 2023-02-06 at 4 12 19 PM

Motivation and Context

Previously, an admin had to run the command rake user:cleanup_cache to clear expired cache #1634 . This button makes it easier to do so.

How Has This Been Tested?

Preliminary steps

  • Enable caching in development by running rails dev:cache
  • In development.rb, replace config.cache_store = :memory_store with config.cache_store = :file_store, "tmp/cache/scores"

Test that rake task clears expired entries

  • For testing purposes, change :expires_in and race_condition_ttl to 5.seconds (in all 3 places)
  • Load the gradesheet of an assessment (e.g. AutoPopulated / Homework0), observe that the path /tmp/cache/scores is populated
  • Wait a few seconds, click Manage Autolab followed by Clear Cache, observe that the (expired) entries are cleared

Test that rake task does not clear unexpired entries

  • Change :expires_in and race_condition_ttl back to their original values
  • Load the gradesheet of an assessment (e.g. AutoPopulated / Homework0), observe that the path /tmp/cache/scores is populated
  • Wait a few seconds, click Manage Autolab followed by Clear Cache, observe that the unexpired entries are not cleared
  • As a sanity check, run rake user:clear_cache and observe that the entries are cleared

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have run rubocop for style check. If you haven't, run overcommit --install && overcommit --sign to use pre-commit hook for linting
  • My change requires a change to the documentation, which is located at Autolab Docs
  • I have updated the documentation accordingly, included in this PR

@KesterTan KesterTan marked this pull request as ready for review February 6, 2023 22:44
@gitstream-cm gitstream-cm bot requested a review from damianhxy February 6, 2023 22:45
@KesterTan KesterTan marked this pull request as draft February 6, 2023 23:07
@damianhxy
Copy link
Member

Could you also update the documentation?

Specifically: https://docs.autolabproject.com/installation/troubleshoot/#no-space-left-on-device

@KesterTan KesterTan marked this pull request as ready for review February 12, 2023 19:26
Copy link
Member

@damianhxy damianhxy left a comment

Choose a reason for hiding this comment

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

  1. Change method to post since it is not an idempotent operation and is vulnerable to CSRF attacks
  2. Improve UX by redirecting to previous page where possible

Copy link
Member

@damianhxy damianhxy left a comment

Choose a reason for hiding this comment

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

LGTM

@KesterTan KesterTan added this pull request to the merge queue Feb 19, 2023
Merged via the queue into master with commit 75ef21c Feb 19, 2023
@KesterTan KesterTan deleted the cache branch February 19, 2023 19:14
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.

None yet

2 participants