perf: Perform `db.set_value` with single query only (backport #18305) (#18349)
* perf: single query `db.set_value`
(cherry picked from commit cee2b50461)
* fix: better cache validation
- Only delete a single doc if we know which doc changed
- Drop all docs other wise (kinda bad, but this isn't used frequently,
will fix when visiting entire caching system again)
(cherry picked from commit bfa6a5fbdf)
Co-authored-by: Ankush Menat <ankush@frappe.io>