Make EchoSeenTime cache entries expire after 1 year

These entries weren't TTLed at all, and so we had millions of records
for inactive users that were being stored forever. If a user doesn't
view their notifications for a year, it's OK for their notifications
badge to go back to the unseen state until they click it.

(The fallback behavior on a cache miss is to act as if the seentime is
the UNIX epoch, which means that any unread notification they have is
more recent than it, and is considered unseen.)

Bug: T222851
Change-Id: I99230d2351b40751a3f2f5123c5f38693120259e
This commit is contained in:
Roan Kattouw 2019-10-04 14:54:07 -07:00 committed by Mobrovac
parent 79ee7582f2
commit ff165c0003

View file

@ -120,9 +120,9 @@ class EchoSeenTime {
// the real cache
$key = $this->getMemcKey( $type );
$cache = self::cache();
$cache->set( $key, $time, 0, BagOStuff::WRITE_CACHE_ONLY );
$cache->set( $key, $time, $cache::TTL_YEAR, BagOStuff::WRITE_CACHE_ONLY );
DeferredUpdates::addCallableUpdate( function () use ( $key, $time, $cache ) {
$cache->set( $key, $time );
$cache->set( $key, $time, $cache::TTL_YEAR );
} );
}