HomePhabricator

resourceloader: Make sure hashmtime cache key is different by language
044713c4dc08Unpublished

Authored by Krinkle.

Unpublished Commit · Learn More

Repository Importing: This repository is still importing.

Description

resourceloader: Make sure hashmtime cache key is different by language

We were continuously invalidating the cache for the
ResourceLoaderLanguageDataModule every time a request for a langauge
other than the previous request came in as they all resulted in
the same cache key.

This could be resolved by adding $context->getLang() to the key
(which would be enough for langdata module, but not enough for
other uses of hashmtime), or by adding $context->getHash() (which
will fragment it for all possible context factor combinations,
slightly overkill for most cases, but would work).

Instead resolving it the same way we did in d3bdda3 for a similar
issue in #getDefinitionMtime: by adding the hash itself to the
key. That way it will solve the problem, including two nice things:

  • Not fragment anymore than necessary (if it doesn't vary by skin, it won't vary by skin, and same for language etc.).
  • Always separate keys when the value is different (if something can very based on other factors, e.g. LocalSettings globals or whatever untracked method may exist for influencing anything, it will all work as expected).
  • Don't keep alternating and incrementing the timestamp while a multi-server infrastructure is syncing code (e.g. old code and new code for the same request context will not result in the same key and each old/new server alternatingly increasing the timestamp, instead the first new server will make the new key and the other servers will gradually start finding the new key with the timestamp of when it was first seen).

Change-Id: Ifa9088c11c388ca6c912e62efc43494e91702603

Details