MapCacheLRU: Serialize maxCacheKeys property

Without this, unserializing a MapCacheLRU object results in maxCacheKeys
set to null, which causes it to completely empty itself as soon as you
try to write to it.

Bug: T218511
Change-Id: I77d42b43f4949a24ffb8a58912eef55cc9281e64
This commit is contained in:
Roan Kattouw 2020-04-15 21:45:20 -07:00
parent 396591a485
commit fb5116028b

View file

@ -355,7 +355,8 @@ class MapCacheLRU implements ExpirationAwareness, Serializable {
public function serialize() {
return serialize( [
'entries' => $this->cache,
'timestamps' => $this->timestamps
'timestamps' => $this->timestamps,
'maxCacheKeys' => $this->maxCacheKeys,
] );
}
@ -363,6 +364,7 @@ class MapCacheLRU implements ExpirationAwareness, Serializable {
$data = unserialize( $serialized );
$this->cache = $data['entries'] ?? [];
$this->timestamps = $data['timestamps'] ?? [];
$this->maxCacheKeys = $data['maxCacheKeys'] ?? count( $this->cache );
$this->epoch = $this->getCurrentTime();
}