/** * Constructs a new cache. * * This constructor requires a storage engine and the cache size as parameters. * * Only storage engines with enabled timestamps are accepted. * * Size determines the maximum number of items this cache can hold. If the provided size differs * from the size of the stored data, this cache will be resized automatically. * * @param StorageEngine the storage engine * @param int $site the size of the cache * @throws InvalidArgumentException if the storage engine doesn't use timestamps */ public function __construct(StorageEngine $engine, $size) { if (!$engine->getUseTimestamps()) { throw new InvalidArgumentException(__CLASS__ . ' requires a storage engine with enabled timestamps'); } $this->engine = $engine; $this->size = $size; $this->resize(); }
public function size() { return $this->engine->size(); }