stash = $stash; } /** @inheritDoc */ public function get($key, callable $callback) { assert(is_string($key) || is_int($key)); $item = $this->stash->getItem((string)$key); $result = $item->get(); if ($item->isMiss()) { $item->lock(); $result = call_user_func($callback); $this->stash->save($item->set($result)); } return $result; } /** @inheritDoc */ public function invalidate($key) { assert(is_string($key) || is_int($key)); $this->stash->getItem((string)$key)->clear(); } /** @inheritDoc */ public function put($key, $value) { assert(is_string($key) || is_int($key)); $this->stash->getItem((string)$key)->set($value); } /** * Create an in-memory implementation of the pool. * * @return StashPool */ public static function createEphemeral() { return new self(new Stash\Pool(new Stash\Driver\Ephemeral())); } }