Elgg
Version 1.11
engine
classes
Elgg
Cache
StashPool.php
Go to the documentation of this file.
1
<?php
2
namespace
Elgg\Cache
;
3
4
use Stash;
5
17
final
class
StashPool
implements
Pool
{
18
20
private
$stash;
21
27
public
function
__construct
(Stash\
Pool
$stash) {
28
$this->stash = $stash;
29
}
30
32
public
function
get
(
$key
, callable $callback) {
33
assert(is_string(
$key
) || is_int(
$key
));
34
35
$item
= $this->stash->getItem((
string
)
$key
);
36
37
$result
=
$item
->get();
38
39
if
(
$item
->isMiss()) {
40
$item
->lock();
41
42
$result
= call_user_func($callback);
43
44
$this->stash->save(
$item
->set(
$result
));
45
}
46
47
return
$result
;
48
}
49
51
public
function
invalidate
(
$key
) {
52
assert(is_string(
$key
) || is_int(
$key
));
53
54
$this->stash->getItem((
string
)
$key
)->clear();
55
}
56
58
public
function
put
(
$key
,
$value
) {
59
assert(is_string(
$key
) || is_int(
$key
));
60
61
$this->stash->getItem((
string
)
$key
)->set(
$value
);
62
}
63
69
public
static
function
createEphemeral
() {
70
return
new
self
(
new
Stash\Pool(
new
Stash\Driver\Ephemeral()));
71
}
72
}
$result
$result
Definition:
set_maintenance_mode.php:11
Elgg\Cache\StashPool
Definition:
StashPool.php:17
Elgg\Cache\StashPool\__construct
__construct(Stash\Pool $stash)
Constructor.
Definition:
StashPool.php:27
Elgg\Cache\StashPool\put
put($key, $value)
@inheritDoc
Definition:
StashPool.php:58
Elgg\Cache\StashPool\createEphemeral
static createEphemeral()
Create an in-memory implementation of the pool.
Definition:
StashPool.php:69
Elgg\Cache\StashPool\invalidate
invalidate($key)
@inheritDoc
Definition:
StashPool.php:51
$item
$item
Definition:
item.php:12
$value
$value
Definition:
longtext.php:26
Elgg\Cache\Pool
Definition:
Pool.php:19
Elgg\Cache
Definition:
LRUCache.php:2
$key
$key
Definition:
summary.php:34
Generated on Fri Aug 29 2025 00:00:37 for Elgg by
1.9.1