28 $this->stash = $stash;
32 public function get(
$key, callable $callback =
null,
$default =
null) {
33 assert(is_string(
$key) || is_int(
$key));
35 $item = $this->stash->getItem((
string)
$key);
39 if (
$item->isMiss()) {
46 $result = call_user_func($callback);
56 assert(is_string(
$key) || is_int(
$key));
58 $this->stash->getItem((
string)
$key)->clear();
63 assert(is_string(
$key) || is_int(
$key));
65 $this->stash->getItem((
string)
$key)->set(
$value);
74 return new self(
new Stash\Pool(
new Stash\Driver\Ephemeral()));
Defers to Stash for the meat of the caching logic.
__construct(Stash\Pool $stash)
Constructor.
static createEphemeral()
Create an in-memory implementation of the pool.
put($key, $value)
@inheritDoc
invalidate($key)
@inheritDoc