<?php
/**
- * Object caching using PHP arrays.
+ * Per-process memory cache for storing items.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
use Wikimedia\Assert\Assert;
/**
- * This is a test of the interface, mainly. It stores things in an associative
- * array, which is not going to persist between program runs.
+ * Simple store for keeping values in an associative array for the current process.
+ *
+ * Data will not persist and is not shared with other processes.
*
* @ingroup Cache
*/
protected function expire( $key ) {
$et = $this->bag[$key][self::KEY_EXP];
- if ( $et == 0 || $et > time() ) {
+ if ( $et == self::TTL_INDEFINITE || $et > time() ) {
return false;
}
}
public function set( $key, $value, $exptime = 0, $flags = 0 ) {
+ // Refresh key position for maxCacheKeys eviction
+ unset( $this->bag[$key] );
$this->bag[$key] = array(
self::KEY_VAL => $value,
self::KEY_EXP => $this->convertExpiry( $exptime )