Cache user data in memory
authorGergő Tisza <tgr.huwiki@gmail.com>
Mon, 29 Feb 2016 23:41:56 +0000 (15:41 -0800)
committerOri.livneh <ori@wikimedia.org>
Tue, 1 Mar 2016 00:19:14 +0000 (00:19 +0000)
commit9c733318107e26644fec33430e9712e51b022ad2
tree6407bebb51bb5a3d68cfb9ac8a7fa07bed85d15b
parent3071f1fad720f1773864621158a0c59b73124896
Cache user data in memory

Stores user data looked up in WAN cache in memory so that lookups in the
same request do not result in new memcached lookups.

Quick and dirty solution, but nicer ones are more difficult:
* no idea what replacing WANObjectCache::get/set with getWithSetCallback
  (which has its own in-process cache) would do, the code is complex
  and completely different
* would be nice to wrap the logic into a proxy object (like CachedBagOStuff)
  but WANObjectCache calls set() internally (and marks it final), so
  inheriting is not safe; the interface and implementation should be
  separated, and that means updating all external callers which do a type
  check.
* ObjectCache::getInstance('hash') cannot be used because it has no
  item limit and this could eat up the memory with a script that iterates
  through lots of users

The patch does not attempt to replicate tombstoning for
User::clearSharedCache('refresh').

Based on Iec1504700a and Idef9a9d3.

Change-Id: I419f356b0c306d16711b433da95dccdb44645154
Co-Authored-By: Ori Livneh <ori@wikimedia.org>
Bug: T128157
includes/user/User.php