ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMemcacheNodesRepository Class Reference
+ Inheritance diagram for ilMemcacheNodesRepository:
+ Collaboration diagram for ilMemcacheNodesRepository:

Public Member Functions

 __construct (private ?ilDBInterface $db=null)
 
 deleteAll ()
 
 store (Node $node)
 
 create (string $host, int $port, int $weight)
 
 getNodes ()
 
 store (Node $node)
 
 create (string $host, int $port, int $weight)
 
 getNodes ()
 
 deleteAll ()
 

Data Fields

const TABLE_NAME = "il_gc_memcache_server"
 

Detailed Description

Definition at line 22 of file class.ilMemcacheNodesRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ilMemcacheNodesRepository::__construct ( private ?ilDBInterface  $db = null)

Definition at line 26 of file class.ilMemcacheNodesRepository.php.

27 {
28 }

Member Function Documentation

◆ create()

ilMemcacheNodesRepository::create ( string  $host,
int  $port,
int  $weight 
)

Implements ILIAS\Cache\Nodes\NodeRepository.

Definition at line 51 of file class.ilMemcacheNodesRepository.php.

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 }

Referenced by store().

+ Here is the caller graph for this function:

◆ deleteAll()

ilMemcacheNodesRepository::deleteAll ( )

Implements ILIAS\Cache\Nodes\NodeRepository.

Definition at line 30 of file class.ilMemcacheNodesRepository.php.

30 : void
31 {
32 if ($this->db === null) {
33 return;
34 }
35 $this->db->manipulate("TRUNCATE TABLE " . self::TABLE_NAME);
36 }

◆ getNodes()

ilMemcacheNodesRepository::getNodes ( )
Returns
Node[]

Implements ILIAS\Cache\Nodes\NodeRepository.

Definition at line 71 of file class.ilMemcacheNodesRepository.php.

71 : 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 }

◆ store()

ilMemcacheNodesRepository::store ( Node  $node)

Implements ILIAS\Cache\Nodes\NodeRepository.

Definition at line 38 of file class.ilMemcacheNodesRepository.php.

38 : 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 }
create(string $host, int $port, int $weight)

References create(), ILIAS\Cache\Nodes\Node\getHost(), ILIAS\Cache\Nodes\Node\getPort(), and ILIAS\Cache\Nodes\Node\getWeight().

+ Here is the call graph for this function:

Field Documentation

◆ TABLE_NAME

const ilMemcacheNodesRepository::TABLE_NAME = "il_gc_memcache_server"

Definition at line 24 of file class.ilMemcacheNodesRepository.php.


The documentation for this class was generated from the following file: