[go: nahoru, domu]

Page MenuHomePhabricator

Cache foreign notification count in memcached
Closed, ResolvedPublic

Description

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.

Event Timeline

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.

Yes, agreed.

Catrope renamed this task from Cache foreign notification count in memcached? to Cache foreign notification count in memcached.Apr 26 2016, 1:30 AM

Probably the best way to do this would be to have a global memc key containing the total global notification count.

Change 285598 had a related patch set uploaded (by Catrope):
NotifUser: Refactor getNotificationCount() and friends, add caching for global counts

https://gerrit.wikimedia.org/r/285598

Change 285598 merged by jenkins-bot:
NotifUser: Refactor getNotificationCount() and friends, add caching for global counts

https://gerrit.wikimedia.org/r/285598