BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
WANObjectCacheReaper Class Reference
Inheritance diagram for WANObjectCacheReaper:
Collaboration diagram for WANObjectCacheReaper:

Public Member Functions

 __construct (WANObjectCache $cache, BagOStuff $store, callable $logCallback, callable $keyCallback, array $params)
 
 setLogger (LoggerInterface $logger)
 
 invoke ($n=100)
 
 getState ()
 

Protected Attributes

 $cache
 
 $store
 
 $logChunkCallback
 
 $keyListCallback
 
 $logger
 
 $channel
 
 $initialStartWindow
 

Detailed Description

Class for scanning through chronological, log-structured data or change logs and locally purging cache keys related to entities that appear in this data.

This is useful for repairing cache when purges are missed by using a reliable stream, such as Kafka or a replicated MySQL table. Purge loss between datacenters is expected to be more common than within them.

Since
1.28

Constructor & Destructor Documentation

WANObjectCacheReaper::__construct ( WANObjectCache  $cache,
BagOStuff  $store,
callable  $logCallback,
callable  $keyCallback,
array  $params 
)
Parameters
WANObjectCache$cacheCache to reap bad keys from
BagOStuff$storeCache to store positions use for locking
callable$logCallbackCallback taking arguments:
  • The starting position as a UNIX timestamp
  • The starting unique ID used for breaking timestamp collisions or null
  • The ending position as a UNIX timestamp
  • The maximum number of results to return It returns a list of maps of (key: cache key, pos: UNIX timestamp, id: unique ID) for each key affected, with the corrosponding event timestamp/ID information. The events should be in ascending order, by (timestamp,id).
callable$keyCallbackCallback taking arguments:
  • The WANObjectCache instance
  • An object from the event log It should return a list of WAN cache keys. The callback must fully duck-type test the object, since can be any model class.
array$paramsAdditional options:
  • channel: the name of the update event stream. Default: WANObjectCache::DEFAULT_PURGE_CHANNEL.
  • initialStartWindow: seconds back in time to start if the position is lost. Default: 1 hour.
  • logger: an SPL monolog instance [optional]

Member Function Documentation

WANObjectCacheReaper::getState ( )
Returns
array|bool Returns (pos, id) map or false if not set
WANObjectCacheReaper::invoke (   $n = 100)
final

Check and reap stale keys based on a chunk of events

Parameters
int$nNumber of events
Returns
int Number of keys checked
WANObjectCacheReaper::setLogger ( LoggerInterface  $logger)

Sets a logger instance on the object.

Parameters
LoggerInterface$logger
Returns
void

Implements Psr\Log\LoggerAwareInterface.


The documentation for this class was generated from the following file: