Skip to content

Commit

Permalink
fix: On migrate flush everything
Browse files Browse the repository at this point in the history
Press is single-deploy, so this is fine.
It's almost equivalent to frappe.clear_cache()
  • Loading branch information
ankush committed Dec 18, 2024
1 parent a8f2bd3 commit f55c7bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
18 changes: 11 additions & 7 deletions press/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@


# These are used for some business logic, they should be manually evicted.
__persistent_cache_keys =[
__persistent_cache_keys = [
"agent-jobs",
"monitor-transactions",
"google_oauth_flow*",
Expand All @@ -373,26 +373,27 @@
# - Adding more keys here will slow down `frappe.clear_cache` but it's "rare" enough.
# - This also means that other "valid" frappe.clear_cache() usage won't clear these keys!
# - Use frappe.cache.flushall() instead.
persistent_cache_keys = __persistent_cache_keys + [
persistent_cache_keys = [
*__persistent_cache_keys,
"agent_job_step_output",
"all_apps",
"app_hooks",
"assets_json",
"assignment_rule_map",
"bootinfo",
"builder.builder*", # path resolution, it has its own cache eviction.
"builder.builder*", # path resolution, it has its own cache eviction.
"db_tables",
"defaults",
"doctype_form_meta",
"doctype_meta"
"doctype_meta",
"doctypes_with_web_view",
"document_cache::*",
"document_naming_rule_map",
"domain_restricted_doctypes",
"domain_restricted_pages",
"energy_point_rule_map",
"frappe.utils.scheduler.schedule_jobs_based_on_activity*", # dormant checks
"frappe.website.page_renderers*", # FW's routing
"frappe.utils.scheduler.schedule_jobs_based_on_activity*", # dormant checks
"frappe.website.page_renderers*", # FW's routing
"home_page",
"information_schema:counts",
"installed_app_modules",
Expand All @@ -403,9 +404,12 @@
"marketplace_apps",
"merged_translations",
"metadata_version",
"server_script_map", # Routing and actual server scripts
"server_script_map", # Routing and actual server scripts
"session",
"table_columns",
"website_page",
"website_route_rules",
]

before_migrate = ["press.overrides.before_after_migrate"]
after_migrate = ["press.overrides.before_after_migrate"]
5 changes: 5 additions & 0 deletions press/overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,8 @@ def after_rename(self, old_name, new_name, merge=False):
WHERE name = %s""",
(new_name, new_name),
)


def before_after_migrate():
# frappe.clear_cache() on press doesn't clear everything. See hooks.py
frappe.cache.flushall()

0 comments on commit f55c7bc

Please sign in to comment.