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

Public Member Functions

 __construct (private readonly ?ilIniFile $client_ini=null, private readonly ?ilDBInterface $db=null)
 
 getConfig ()
 
 toConfig ()
 
 readFromIniFile (ilIniFile $client_ini)
 
 getNodesRepository ()
 
 storeToIniFile (ilIniFile $client_ini)
 
 setActive (bool $active)
 
 setService (string $service)
 
 addMemcachedNode (Node $node)
 
 getMemcachedNodes ()
 
 resetActivatedComponents ()
 
 activateAll ()
 
 addActivatedComponent (string $component)
 

Private Attributes

Config $config = null
 @readonly More...
 
bool $active = true
 
string $service = Config::PHPSTATIC
 
array $components = []
 
array $nodes = []
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilGlobalCacheSettingsAdapter::__construct ( private readonly ?ilIniFile  $client_ini = null,
private readonly ?ilDBInterface  $db = null 
)

Definition at line 40 of file class.ilGlobalCacheSettingsAdapter.php.

43 {
44 if ($this->client_ini !== null) {
45 $this->readFromIniFile($this->client_ini);
46 }
47 $this->config = $this->toConfig();
48 }

References readFromIniFile(), and toConfig().

+ Here is the call graph for this function:

Member Function Documentation

◆ activateAll()

ilGlobalCacheSettingsAdapter::activateAll ( )

Definition at line 151 of file class.ilGlobalCacheSettingsAdapter.php.

151 : void
152 {
153 $this->components = ['*'];
154 }
Class ilChatroomConfigFileHandler \ILIAS\Chatroom\classes.

◆ addActivatedComponent()

ilGlobalCacheSettingsAdapter::addActivatedComponent ( string  $component)

Definition at line 156 of file class.ilGlobalCacheSettingsAdapter.php.

156 : void
157 {
158 $this->components[] = $component;
159 }

◆ addMemcachedNode()

ilGlobalCacheSettingsAdapter::addMemcachedNode ( Node  $node)

Definition at line 136 of file class.ilGlobalCacheSettingsAdapter.php.

136 : void
137 {
138 $this->nodes[] = $node;
139 }

Referenced by readFromIniFile().

+ Here is the caller graph for this function:

◆ getConfig()

ilGlobalCacheSettingsAdapter::getConfig ( )

Definition at line 50 of file class.ilGlobalCacheSettingsAdapter.php.

50 : Config
51 {
52 return $this->config ?? $this->toConfig();
53 }

References toConfig().

+ Here is the call graph for this function:

◆ getMemcachedNodes()

ilGlobalCacheSettingsAdapter::getMemcachedNodes ( )

Definition at line 141 of file class.ilGlobalCacheSettingsAdapter.php.

141 : array
142 {
143 return $this->nodes;
144 }

References $nodes.

◆ getNodesRepository()

ilGlobalCacheSettingsAdapter::getNodesRepository ( )

Definition at line 99 of file class.ilGlobalCacheSettingsAdapter.php.

Referenced by readFromIniFile(), storeToIniFile(), and toConfig().

+ Here is the caller graph for this function:

◆ readFromIniFile()

ilGlobalCacheSettingsAdapter::readFromIniFile ( ilIniFile  $client_ini)

Definition at line 65 of file class.ilGlobalCacheSettingsAdapter.php.

65 : bool
66 {
67 $this->active = (bool) $client_ini->readVariable('cache', 'activate_global_cache');
68 $service_type = $client_ini->readVariable('cache', 'global_cache_service_type');
69 if (is_numeric($service_type)) {
70 $service_type = match ((int) $service_type) {
71 0 => Config::PHPSTATIC,
72 2 => Config::MEMCACHED,
73 3 => Config::APCU,
74 default => Config::PHPSTATIC,
75 };
76 }
77 $this->service = $service_type;
78 $read_group = $client_ini->readGroup('cache_activated_components');
79
80 $this->components = array_unique(
81 array_map(static function (string $component): string {
82 if ($component === 'all') {
83 return '*';
84 }
85 return $component;
86 }, array_keys($read_group))
87 );
88 $this->nodes = [];
89 if ($this->db !== null) {
90 $repo = $this->getNodesRepository();
91 foreach ($repo->getNodes() as $node) {
92 $this->addMemcachedNode($node);
93 }
94 }
95
96 return true;
97 }

References addMemcachedNode(), and getNodesRepository().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetActivatedComponents()

ilGlobalCacheSettingsAdapter::resetActivatedComponents ( )

Definition at line 146 of file class.ilGlobalCacheSettingsAdapter.php.

146 : void
147 {
148 $this->components = [];
149 }

◆ setActive()

ilGlobalCacheSettingsAdapter::setActive ( bool  $active)

Definition at line 126 of file class.ilGlobalCacheSettingsAdapter.php.

126 : void
127 {
128 $this->active = $active;
129 }

References $active.

◆ setService()

ilGlobalCacheSettingsAdapter::setService ( string  $service)

Definition at line 131 of file class.ilGlobalCacheSettingsAdapter.php.

131 : void
132 {
133 $this->service = $service;
134 }

References $service.

◆ storeToIniFile()

ilGlobalCacheSettingsAdapter::storeToIniFile ( ilIniFile  $client_ini)

Definition at line 104 of file class.ilGlobalCacheSettingsAdapter.php.

104 : bool
105 {
106 $client_ini->setVariable('cache', 'activate_global_cache', $this->active ? '1' : '0');
107 $client_ini->setVariable('cache', 'global_cache_service_type', $this->service);
108 $client_ini->removeGroup('cache_activated_components');
109 $client_ini->addGroup('cache_activated_components');
110 foreach ($this->components as $component) {
111 $client_ini->setVariable('cache_activated_components', $component, '1');
112 }
113
114 // store nodes to db
115 if ($this->db !== null) {
116 $repo = $this->getNodesRepository();
117 $repo->deleteAll();
118 foreach ($this->nodes as $node) {
119 $repo->store($node);
120 }
121 }
122
123 return $client_ini->write();
124 }
write()
save ini-file-data to filesystem

References getNodesRepository(), and ilIniFile\write().

+ Here is the call graph for this function:

◆ toConfig()

ilGlobalCacheSettingsAdapter::toConfig ( )

Definition at line 55 of file class.ilGlobalCacheSettingsAdapter.php.

55 : Config
56 {
57 return new Config(
58 $this->service,
59 $this->active,
60 $this->components,
61 $this->getNodesRepository()
62 );
63 }

References getNodesRepository().

Referenced by __construct(), and getConfig().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $active

bool ilGlobalCacheSettingsAdapter::$active = true
private

Definition at line 32 of file class.ilGlobalCacheSettingsAdapter.php.

Referenced by setActive().

◆ $components

array ilGlobalCacheSettingsAdapter::$components = []
private

Definition at line 34 of file class.ilGlobalCacheSettingsAdapter.php.

◆ $config

Config ilGlobalCacheSettingsAdapter::$config = null
private

@readonly

Definition at line 31 of file class.ilGlobalCacheSettingsAdapter.php.

◆ $nodes

array ilGlobalCacheSettingsAdapter::$nodes = []
private

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

Referenced by getMemcachedNodes().

◆ $service

string ilGlobalCacheSettingsAdapter::$service = Config::PHPSTATIC
private

Definition at line 33 of file class.ilGlobalCacheSettingsAdapter.php.

Referenced by setService().


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