ILIAS
trunk Revision v11.0_alpha-3011-gc6b235a2e85
◀ ilDoc Overview
class.ilMemcacheNodesRepository.php
Go to the documentation of this file.
1
<?php
2
19
use
ILIAS\Cache\Nodes\NodeRepository
;
20
use
ILIAS\Cache\Nodes\Node
;
21
22
class
ilMemcacheNodesRepository
implements
NodeRepository
23
{
24
public
const
TABLE_NAME
=
"il_gc_memcache_server"
;
25
26
public
function
__construct
(
private
?
ilDBInterface
$db =
null
)
27
{
28
}
29
30
public
function
deleteAll
(): void
31
{
32
if
($this->db ===
null
) {
33
return
;
34
}
35
$this->db->manipulate(
"TRUNCATE TABLE "
. self::TABLE_NAME);
36
}
37
38
public
function
store
(
Node
$node):
Node
39
{
40
if
($this->db ===
null
) {
41
return
$node;
42
}
43
$this->
create
(
44
$node->
getHost
(),
45
$node->
getPort
(),
46
$node->
getWeight
()
47
);
48
return
$node;
49
}
50
51
public
function
create
(
52
string
$host,
53
int
$port,
54
int
$weight
55
):
Node
{
56
$node = new
Node
($host, $port, $weight);
57
if
($this->db !=
null
) {
58
$next_id = $this->db->nextId(self::TABLE_NAME);
59
$this->db->insert(self::TABLE_NAME, [
60
"id"
=> [
"integer"
, $next_id],
61
"status"
=> [
"integer"
,
true
],
62
"host"
=> [
"text"
, $node->getHost()],
63
"port"
=> [
"integer"
, $node->getPort()],
64
"weight"
=> [
"integer"
, $node->getWeight()],
65
"flush_needed"
=> [
"integer"
,
false
]
66
]);
67
}
68
return
$node;
69
}
70
71
public
function
getNodes
(): array
72
{
73
if
($this->db ===
null
) {
74
return
[];
75
}
76
$set = $this->db->query(
"SELECT * FROM "
. self::TABLE_NAME);
77
$nodes = [];
78
while
($rec = $this->db->fetchAssoc($set)) {
79
$nodes[] =
new
Node
(
80
$rec[
"host"
],
81
(
int
) $rec[
"port"
],
82
(
int
) $rec[
"weight"
]
83
);
84
}
85
return
$nodes;
86
}
87
}
ILIAS\Cache\Nodes\Node
Definition:
Node.php:27
ILIAS\Cache\Nodes\Node\getHost
getHost()
Definition:
Node.php:35
ILIAS\Cache\Nodes\Node\getPort
getPort()
Definition:
Node.php:40
ILIAS\Cache\Nodes\Node\getWeight
getWeight()
Definition:
Node.php:45
ilMemcacheNodesRepository
Definition:
class.ilMemcacheNodesRepository.php:23
ilMemcacheNodesRepository\TABLE_NAME
const TABLE_NAME
Definition:
class.ilMemcacheNodesRepository.php:24
ilMemcacheNodesRepository\store
store(Node $node)
Definition:
class.ilMemcacheNodesRepository.php:38
ilMemcacheNodesRepository\getNodes
getNodes()
Definition:
class.ilMemcacheNodesRepository.php:71
ilMemcacheNodesRepository\create
create(string $host, int $port, int $weight)
Definition:
class.ilMemcacheNodesRepository.php:51
ilMemcacheNodesRepository\deleteAll
deleteAll()
Definition:
class.ilMemcacheNodesRepository.php:30
ilMemcacheNodesRepository\__construct
__construct(private ?ilDBInterface $db=null)
Definition:
class.ilMemcacheNodesRepository.php:26
ILIAS\Cache\Nodes\NodeRepository
Definition:
NodeRepository.php:27
ilDBInterface
Interface ilDBInterface.
Definition:
interface.ilDBInterface.php:30
components
ILIAS
Cache
classes
class.ilMemcacheNodesRepository.php
Generated on Sat Oct 18 2025 23:02:41 for ILIAS by
1.9.4 (using
Doxyfile
)