We cache the notification count (and also timestamp, for both alerts and messages separately) in memcached, but that count only includes local notifications. We don't cache anything in memcached for foreign notifications:
public function getAlertCount( $cached = true, $dbSource = DB_SLAVE ) { $count = $this->getNotificationCount( $cached, $dbSource, EchoAttributeManager::ALERT ); $count += $this->foreignNotifications->getCount( EchoAttributeManager::ALERT ); return $count; }
getNotificationCount uses memcached if $cached = true and queries up to a hundred DB rows if $cached = false. OTOH, foreignNotifications->getCount() is not cached at all; it selects one row per wiki where the user has unread notifications, and each row contains the number of notifications on that wiki. That could potentially also be in the hundreds of rows, but it's unlikely to be more than a dozen.
Should we cache this in memcached too? My gut says it can't hurt, especially since we already do a getMulti() to memc so there would be essentially zero additional cost to add a few more keys to that.