Context
Audit follow-up (scale paper cut, not urgent). Volume is tiny today (single-digit unread rows network-wide), so this is pre-emptive.
extrachill_users_get_unread_notification_count() (inc/notifications/bell.php) runs a COUNT(*) on the substrate table on every page load for every logged-in user, via the ability. Fine now; a needless repeated query at scale.
Proposal
Cache the per-user unread count in object cache (Redis is active) with a short TTL, busted on write:
- read:
wp_cache_get( "ec_notif_unread_{$user_id}", 'ec_notifications' ), fall back to the COUNT and set.
- bust in
ec_users_notify() (new notification) and ec_users_mark_notifications_read() / clear (count changes).
Keep the busting in the substrate (service.php) so every writer invalidates consistently.
Parent epic: Extra-Chill/extrachill-community#82.
Context
Audit follow-up (scale paper cut, not urgent). Volume is tiny today (single-digit unread rows network-wide), so this is pre-emptive.
extrachill_users_get_unread_notification_count()(inc/notifications/bell.php) runs aCOUNT(*)on the substrate table on every page load for every logged-in user, via the ability. Fine now; a needless repeated query at scale.Proposal
Cache the per-user unread count in object cache (Redis is active) with a short TTL, busted on write:
wp_cache_get( "ec_notif_unread_{$user_id}", 'ec_notifications' ), fall back to the COUNT and set.ec_users_notify()(new notification) andec_users_mark_notifications_read()/ clear (count changes).Keep the busting in the substrate (service.php) so every writer invalidates consistently.
Parent epic: Extra-Chill/extrachill-community#82.