Skip to content

Commit

Permalink
Add action clear-cache-complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannah Bast committed Dec 16, 2023
1 parent b9f391d commit 08c0619
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions qlever
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,33 @@ class Actions:
raise ActionException(f"Failed to get cache stats and settings: "
f"{e}")

@track_action_rank
def action_clear_cache_complete(self, only_show=False):
"""
Action that clears the complete cache.
"""

# Construct the curl command.
access_token = self.config['server']['access_token']
clear_cache_cmd = (f"curl -s {self.config['server']['url']} "
f"--data-urlencode \"cmd=clear-cache-complete\" "
f"--data-urlencode \"access-token={access_token}\"")

# Show it.
self.show(clear_cache_cmd, only_show)
if only_show:
return

# Execute it.
try:
subprocess.run(clear_cache_cmd, shell=True,
stdout=subprocess.DEVNULL)
print("Cache cleared (both pinned and unpinned entries)")
print()
self.action_cache_stats_and_settings(only_show)
except Exception as e:
raise ActionException(f"Failed to clear the cache: {e}")

@track_action_rank
def action_autocompletion_warmup(self, only_show=False):
"""
Expand Down

0 comments on commit 08c0619

Please sign in to comment.