ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
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
 
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.

References null, readFromIniFile(), and toConfig().

43  {
44  if ($this->client_ini !== null) {
45  $this->readFromIniFile($this->client_ini);
46  }
47  $this->config = $this->toConfig();
48  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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 .

◆ addActivatedComponent()

ilGlobalCacheSettingsAdapter::addActivatedComponent ( string  $component)

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

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

◆ addMemcachedNode()

ilGlobalCacheSettingsAdapter::addMemcachedNode ( Node  $node)

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

Referenced by readFromIniFile().

136  : void
137  {
138  $this->nodes[] = $node;
139  }
+ Here is the caller graph for this function:

◆ getConfig()

ilGlobalCacheSettingsAdapter::getConfig ( )

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

References toConfig().

50  : Config
51  {
52  return $this->config ?? $this->toConfig();
53  }
+ Here is the call graph for this function:

◆ getMemcachedNodes()

ilGlobalCacheSettingsAdapter::getMemcachedNodes ( )

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

References $nodes.

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

◆ 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.

References addMemcachedNode(), getNodesRepository(), null, ilIniFile\readGroup(), and ilIniFile\readVariable().

Referenced by __construct().

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  }
readGroup(string $a_group_name)
returns an associative array of the variables in one group
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
readVariable(string $a_group, string $a_var_name)
reads a single variable from a group
Class ilChatroomConfigFileHandler .
+ 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  }
Class ilChatroomConfigFileHandler .

◆ setActive()

ilGlobalCacheSettingsAdapter::setActive ( bool  $active)

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

References $active.

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

◆ setService()

ilGlobalCacheSettingsAdapter::setService ( string  $service)

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

References $service.

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

◆ storeToIniFile()

ilGlobalCacheSettingsAdapter::storeToIniFile ( ilIniFile  $client_ini)

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

References ilIniFile\addGroup(), getNodesRepository(), null, ilIniFile\removeGroup(), ilIniFile\setVariable(), and ilIniFile\write().

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  }
addGroup(string $a_group_name)
adds a new group
write()
save ini-file-data to filesystem
setVariable(string $a_group_name, string $a_var_name, string $a_var_value)
sets a variable in a group
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
removeGroup(string $a_group_name)
removes a group
Class ilChatroomConfigFileHandler .
+ Here is the call graph for this function:

◆ toConfig()

ilGlobalCacheSettingsAdapter::toConfig ( )

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

References getNodesRepository().

Referenced by __construct(), and getConfig().

55  : Config
56  {
57  return new Config(
58  $this->service,
59  $this->active,
60  $this->components,
61  $this->getNodesRepository()
62  );
63  }
Class ilChatroomConfigFileHandler .
+ 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

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: