Skip to content

Commit

Permalink
perf: protect important caches from frappe.rename_doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Dec 18, 2024
1 parent d26510e commit a8f2bd3
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions press/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,57 @@
page_renderer = ["press.metrics.MetricsRenderer"]

export_python_type_annotations = True


# These are used for some business logic, they should be manually evicted.
__persistent_cache_keys =[
"agent-jobs",
"monitor-transactions",
"google_oauth_flow*",
"fc_oauth_state*",
"one_time_login_key*",
"press-auth-logs",
]

# `frappe.rename_doc` erases all caches, this hook preserves some of them.
# Note:
# - These are only "most used" cache keys. This lessens the impact of renames but doesn't eliminate them.
# - 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 + [
"agent_job_step_output",
"all_apps",
"app_hooks",
"assets_json",
"assignment_rule_map",
"bootinfo",
"builder.builder*", # path resolution, it has its own cache eviction.
"db_tables",
"defaults",
"doctype_form_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
"home_page",
"information_schema:counts",
"installed_app_modules",
"ip_country_map",
"is_table",
"languages",
"last_db_session_update",
"marketplace_apps",
"merged_translations",
"metadata_version",
"server_script_map", # Routing and actual server scripts
"session",
"table_columns",
"website_page",
"website_route_rules",
]

0 comments on commit a8f2bd3

Please sign in to comment.