objectcache: move version numbers to the main wrapper in WANObjectCache
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 9 Jul 2019 01:17:04 +0000 (18:17 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 12 Jul 2019 01:04:50 +0000 (18:04 -0700)
commit611e2d55963b91b316465dcd32e58adc2538192a
tree3ed6c2ff552d1097d0fdca8acc6765d80372c4c5
parent5be1301617dd18fd2e1640b558aff53ba6442096
objectcache: move version numbers to the main wrapper in WANObjectCache

Add FLD_VALUE_VERSION key to the value wrapper array to hold the version
number used in getWithSetCallback(). Remove the VFLD_* wrapper array from
FLD_VALUE for versioned values.

Keys stored with the old VFLD_VERSION and VFLD_DATA fields will be seen as
having the wrong version. The previous WAN cache code will see the new keys
that use FLD_VALUE_VERSION as having the wrong version too. In either case,
the usual variant key logic applies, so there should not be any issues.

This means that moving from a non-versioned to a versioned cache key is no
longer a breaking change when, for the same key, some code passes a version
number to getWithSetCallback() while other code does not.

Also:
* Make "pcTTL" respect the version number for sanity
* Make sure set() respects TTL_UNCACHEABLE for completeness
* Track slow regeneration callback runtime in FLD_GENERATION_TIME
* Remove is_callable() check overhead and rely on PHP Error instances
* Refactor unwrap() to return a more immediately useful value
* Simplify getNonProcessCachedKeys() signature by using $opts
* Split out PURGE_* constants for purge entries since those keys are
  never stored in any serialize value but are only in PHP arrays
* Rename doGetWithSetCallback() to be more succinct
* Rename and reorganize some variables for clarity

Change-Id: I4060b19583cdfd9fa36c91d7014441eeef4b3609
includes/libs/objectcache/WANObjectCache.php
tests/phpunit/includes/libs/objectcache/WANObjectCacheTest.php