@Krinkle and I have been discussing reducing WANObjectCache callback options. To begin with, we're surveying consumers of minAsOf and we want to attempt to replace them with the touchedCallback.
A Codesearch survey: https://codesearch.wmcloud.org/deployed/?q=%27minAsOf%27+%3D%3E shows the usage pattern such as:
$value = $this->wanCache->getWithSetCallback( $key, TTL, function () { // callback definition }, [ 'minAsOf' => INF ] )
... with a few other unique cases that are fundamentally variants of the above snippet. This pattern forces the getWithSet callback to run every time, bypassing the TTL, since we want to double-check that the cache value is "fresh" and can be reused. If otherwise, the cache should be re-computed synchronously in the current function call with the new value returned to the caller.
We think that it is possible to replace the usage of minAsOf with touchedCallback in these cases, and want to try it out there by potentially (if possible) removing the option if having both is redundant (based on usage needs). This could turn out to be *not true*, and the experiment could be closed, with lessons captured and documented for a future audience.
The replacement for the majority of the cases, per the survey, would be something like:
$value = $this->wanCache->getWithSetCallback( $key, TTL, function () { // callback definition }, [ 'touchedCallback' => fn () => time() ] )
or
$value = $this->wanCache->getWithSetCallback( $key, TTL, function () { // callback definition }, [ 'touchedCallback' => fn () => INF ] )
The key result we want to achieve (with the bigger picture in mind) is to reduce the number of callback options provided by WANCache, thereby reducing what developers need to understand and making it more likely they'll use the platform and use it correctly, instead of avoiding it or using the wrong option due to there being too many similar capabilities provided.