28 $this->stash = $stash;
32 public function get(
$key, callable $callback) {
33 assert(is_string(
$key) || is_int(
$key));
35 $item = $this->stash->getItem((
string)
$key);
39 if (
$item->isMiss()) {
42 $result = call_user_func($callback);
52 assert(is_string(
$key) || is_int(
$key));
54 $this->stash->getItem((
string)
$key)->clear();
59 assert(is_string(
$key) || is_int(
$key));
61 $this->stash->getItem((
string)
$key)->set(
$value);
70 return new self(
new Stash\Pool(
new Stash\Driver\Ephemeral()));
__construct(Stash\Pool $stash)
Constructor.
static createEphemeral()
Create an in-memory implementation of the pool.