ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilGlobalCacheSettings Class Reference

Class ilGlobalCacheSettings. More...

+ Inheritance diagram for ilGlobalCacheSettings:
+ Collaboration diagram for ilGlobalCacheSettings:

Public Member Functions

 readFromIniFile (ilIniFile $ilIniFile)
 
 writeToIniFile (ilIniFile $ilIniFile)
 
 activateAll ()
 
 addActivatedComponent ($component)
 
 resetActivatedComponents ()
 
 isComponentActivated ($component)
 
 areAllComponentActivated ()
 
 getService ()
 
 setService ($service)
 
 getActivatedComponents ()
 
 setActivatedComponents ($activated_components)
 
 isActive ()
 
 setActive ($active)
 
 getLogLevel ()
 
 setLogLevel ($log_level)
 
 __toString ()
 
 addMemcachedNode (ilMemcacheServer $node_id)
 
 getMemcachedNodes ()
 

Data Fields

const LOG_LEVEL_FORCED = -1
 
const LOG_LEVEL_NONE = 0
 
const LOG_LEVEL_SHY = 1
 
const LOG_LEVEL_NORMAL = 2
 
const LOG_LEVEL_CHATTY = 3
 
const INI_HEADER_CACHE = 'cache'
 
const INI_FIELD_ACTIVATE_GLOBAL_CACHE = 'activate_global_cache'
 
const INI_FIELD_GLOBAL_CACHE_SERVICE_TYPE = 'global_cache_service_type'
 
const INI_HEADER_CACHE_ACTIVATED_COMPONENTS = 'cache_activated_components'
 
const INI_FIELD_LOG_LEVEL = 'log_level'
 

Protected Member Functions

 checkIniHeader (ilIniFile $ilIniFile)
 
 getLogLevelName ()
 
 lookupLogLevelName ($level)
 

Protected Attributes

 $service = ilGlobalCache::TYPE_STATIC
 
 $activated_components = array()
 
 $active = false
 
 $log_level = self::LOG_LEVEL_NONE
 
 $memcached_nodes = []
 

Detailed Description

Class ilGlobalCacheSettings.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
1.0.0

Definition at line 12 of file class.ilGlobalCacheSettings.php.

Member Function Documentation

◆ __toString()

ilGlobalCacheSettings::__toString ( )

Definition at line 220 of file class.ilGlobalCacheSettings.php.

References $log_level, $service, getActivatedComponents(), getLogLevelName(), getService(), and ilGlobalCache\lookupServiceClassName().

Referenced by writeToIniFile().

221  {
222  $service = 'Service: ' . ($this->getService() > 0 ? ilGlobalCache::lookupServiceClassName($this->getService()) : 'none');
223  $activated = 'Activated Components: ' . implode(', ', $this->getActivatedComponents());
224  $log_level = 'Log Level: ' . $this->getLogLevelName();
225 
226  return implode("\n", array( '', '', $service, $activated, $log_level, '' ));
227  }
static lookupServiceClassName($service_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ activateAll()

ilGlobalCacheSettings::activateAll ( )

Definition at line 90 of file class.ilGlobalCacheSettings.php.

References addActivatedComponent(), and ilGlobalCache\getAvailableComponents().

91  {
92  foreach (ilGlobalCache::getAvailableComponents() as $comp) {
93  $this->addActivatedComponent($comp);
94  }
95  }
static getAvailableComponents()
+ Here is the call graph for this function:

◆ addActivatedComponent()

ilGlobalCacheSettings::addActivatedComponent (   $component)
Parameters
$component

Definition at line 101 of file class.ilGlobalCacheSettings.php.

Referenced by activateAll(), and readFromIniFile().

102  {
103  $this->activated_components[] = $component;
104  $this->activated_components = array_unique($this->activated_components);
105  }
+ Here is the caller graph for this function:

◆ addMemcachedNode()

ilGlobalCacheSettings::addMemcachedNode ( ilMemcacheServer  $node_id)

Definition at line 256 of file class.ilGlobalCacheSettings.php.

256  : void
257  {
258  $this->memcached_nodes[] = $node_id;
259  }

◆ areAllComponentActivated()

ilGlobalCacheSettings::areAllComponentActivated ( )
Returns
bool

Definition at line 128 of file class.ilGlobalCacheSettings.php.

References ilGlobalCache\getAvailableComponents().

129  {
130  return count($this->activated_components) == count(ilGlobalCache::getAvailableComponents());
131  }
static getAvailableComponents()
+ Here is the call graph for this function:

◆ checkIniHeader()

ilGlobalCacheSettings::checkIniHeader ( ilIniFile  $ilIniFile)
protected
Parameters
ilIniFile$ilIniFile

Definition at line 191 of file class.ilGlobalCacheSettings.php.

References ilIniFile\addGroup(), and ilIniFile\readGroup().

Referenced by readFromIniFile().

192  {
193  if (!$ilIniFile->readGroup(self::INI_HEADER_CACHE)) {
194  $ilIniFile->addGroup(self::INI_HEADER_CACHE);
195  }
196  if (!$ilIniFile->readGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS)) {
197  $ilIniFile->addGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
198  }
199  }
addGroup($a_group_name)
adds a new group public
readGroup($a_group_name)
returns an associative array of the variables in one group public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActivatedComponents()

ilGlobalCacheSettings::getActivatedComponents ( )
Returns
array

Definition at line 155 of file class.ilGlobalCacheSettings.php.

References $activated_components.

Referenced by __toString(), and ilGlobalCache\setup().

+ Here is the caller graph for this function:

◆ getLogLevel()

ilGlobalCacheSettings::getLogLevel ( )
Returns
int

Definition at line 205 of file class.ilGlobalCacheSettings.php.

References $log_level.

Referenced by getLogLevelName(), and writeToIniFile().

+ Here is the caller graph for this function:

◆ getLogLevelName()

ilGlobalCacheSettings::getLogLevelName ( )
protected
Returns
string

Definition at line 233 of file class.ilGlobalCacheSettings.php.

References getLogLevel(), and lookupLogLevelName().

Referenced by __toString().

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

◆ getMemcachedNodes()

ilGlobalCacheSettings::getMemcachedNodes ( )
Returns
ilMemcacheServer[]

Definition at line 264 of file class.ilGlobalCacheSettings.php.

References $memcached_nodes.

264  : array
265  {
266  return $this->memcached_nodes;
267  }

◆ getService()

ilGlobalCacheSettings::getService ( )
Returns
int

Definition at line 137 of file class.ilGlobalCacheSettings.php.

References $service.

Referenced by __toString(), and writeToIniFile().

138  {
139  return $this->service;
140  }
+ Here is the caller graph for this function:

◆ isActive()

ilGlobalCacheSettings::isActive ( )
Returns
boolean

Definition at line 173 of file class.ilGlobalCacheSettings.php.

References $active.

Referenced by readFromIniFile(), and writeToIniFile().

174  {
175  return $this->active;
176  }
+ Here is the caller graph for this function:

◆ isComponentActivated()

ilGlobalCacheSettings::isComponentActivated (   $component)
Parameters
$component
Returns
bool

Definition at line 119 of file class.ilGlobalCacheSettings.php.

Referenced by writeToIniFile().

120  {
121  return in_array($component, $this->activated_components);
122  }
+ Here is the caller graph for this function:

◆ lookupLogLevelName()

ilGlobalCacheSettings::lookupLogLevelName (   $level)
protected
Parameters
$level
Returns
string

Definition at line 244 of file class.ilGlobalCacheSettings.php.

Referenced by getLogLevelName().

245  {
246  $r = new ReflectionClass($this);
247  foreach ($r->getConstants() as $k => $v) {
248  if (strpos($k, 'LOG_LEVEL') === 0 and $v == $level) {
249  return $k;
250  }
251  }
252 
253  return '';
254  }
+ Here is the caller graph for this function:

◆ readFromIniFile()

ilGlobalCacheSettings::readFromIniFile ( ilIniFile  $ilIniFile)
Parameters
ilIniFile$ilIniFile

Definition at line 49 of file class.ilGlobalCacheSettings.php.

References addActivatedComponent(), checkIniHeader(), isActive(), ilIniFile\readGroup(), ilIniFile\readVariable(), resetActivatedComponents(), setActive(), setLogLevel(), and setService().

50  {
51  $this->checkIniHeader($ilIniFile);
52  $this->setActive($ilIniFile->readVariable(self::INI_HEADER_CACHE, self::INI_FIELD_ACTIVATE_GLOBAL_CACHE));
53  $this->setService($ilIniFile->readVariable(self::INI_HEADER_CACHE, self::INI_FIELD_GLOBAL_CACHE_SERVICE_TYPE));
54  $this->setLogLevel($ilIniFile->readVariable(self::INI_HEADER_CACHE, self::INI_FIELD_LOG_LEVEL));
55  if (!$this->isActive()) {
56  $this->resetActivatedComponents();
57  } else {
58  $cache_components = $ilIniFile->readGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
59  if (is_array($cache_components)) {
60  foreach ($cache_components as $comp => $v) {
61  if ($v) {
62  $this->addActivatedComponent($comp);
63  }
64  }
65  }
66  }
67  }
checkIniHeader(ilIniFile $ilIniFile)
readVariable($a_group, $a_var_name)
reads a single variable from a group public
readGroup($a_group_name)
returns an associative array of the variables in one group public
+ Here is the call graph for this function:

◆ resetActivatedComponents()

ilGlobalCacheSettings::resetActivatedComponents ( )

Definition at line 108 of file class.ilGlobalCacheSettings.php.

Referenced by readFromIniFile().

109  {
110  $this->activated_components = array();
111  }
+ Here is the caller graph for this function:

◆ setActivatedComponents()

ilGlobalCacheSettings::setActivatedComponents (   $activated_components)
Parameters
array$activated_components

Definition at line 164 of file class.ilGlobalCacheSettings.php.

References $activated_components.

165  {
166  $this->activated_components = $activated_components;
167  }

◆ setActive()

ilGlobalCacheSettings::setActive (   $active)
Parameters
boolean$active

Definition at line 182 of file class.ilGlobalCacheSettings.php.

References $active.

Referenced by readFromIniFile().

183  {
184  $this->active = $active;
185  }
+ Here is the caller graph for this function:

◆ setLogLevel()

ilGlobalCacheSettings::setLogLevel (   $log_level)
Parameters
int$log_level

Definition at line 214 of file class.ilGlobalCacheSettings.php.

References $log_level.

Referenced by readFromIniFile().

215  {
216  $this->log_level = $log_level;
217  }
+ Here is the caller graph for this function:

◆ setService()

ilGlobalCacheSettings::setService (   $service)
Parameters
int$service

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

References $service.

Referenced by readFromIniFile().

147  {
148  $this->service = $service;
149  }
+ Here is the caller graph for this function:

◆ writeToIniFile()

ilGlobalCacheSettings::writeToIniFile ( ilIniFile  $ilIniFile)
Parameters
ilIniFile$ilIniFile

Definition at line 73 of file class.ilGlobalCacheSettings.php.

References __toString(), ilIniFile\addGroup(), ilGlobalCache\getAvailableComponents(), getLogLevel(), getService(), isActive(), isComponentActivated(), ilGlobalCache\log(), ilIniFile\removeGroup(), ilIniFile\setVariable(), and ilIniFile\write().

74  {
75  $ilIniFile->setVariable(self::INI_HEADER_CACHE, self::INI_FIELD_ACTIVATE_GLOBAL_CACHE, $this->isActive() ? '1' : '0');
76  $ilIniFile->setVariable(self::INI_HEADER_CACHE, self::INI_FIELD_GLOBAL_CACHE_SERVICE_TYPE, $this->getService());
77  $ilIniFile->setVariable(self::INI_HEADER_CACHE, self::INI_FIELD_LOG_LEVEL, $this->getLogLevel());
78 
79  $ilIniFile->removeGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
80  $ilIniFile->addGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
81  foreach (ilGlobalCache::getAvailableComponents() as $comp) {
82  $ilIniFile->setVariable(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS, $comp, $this->isComponentActivated($comp) ? '1' : '0');
83  }
84  if ($ilIniFile->write()) {
85  ilGlobalCache::log('saved new settings: ' . $this->__toString(), self::LOG_LEVEL_FORCED);
86  }
87  }
setVariable($a_group_name, $a_var_name, $a_var_value)
sets a variable in a group public
write()
save ini-file-data to filesystem private
removeGroup($a_group_name)
removes a group public
static getAvailableComponents()
static log($message, $log_level)
addGroup($a_group_name)
adds a new group public
+ Here is the call graph for this function:

Field Documentation

◆ $activated_components

ilGlobalCacheSettings::$activated_components = array()
protected

◆ $active

ilGlobalCacheSettings::$active = false
protected

Definition at line 35 of file class.ilGlobalCacheSettings.php.

Referenced by isActive(), and setActive().

◆ $log_level

ilGlobalCacheSettings::$log_level = self::LOG_LEVEL_NONE
protected

Definition at line 39 of file class.ilGlobalCacheSettings.php.

Referenced by __toString(), getLogLevel(), and setLogLevel().

◆ $memcached_nodes

ilGlobalCacheSettings::$memcached_nodes = []
protected

Definition at line 43 of file class.ilGlobalCacheSettings.php.

Referenced by getMemcachedNodes().

◆ $service

ilGlobalCacheSettings::$service = ilGlobalCache::TYPE_STATIC
protected

Definition at line 27 of file class.ilGlobalCacheSettings.php.

Referenced by __toString(), getService(), and setService().

◆ INI_FIELD_ACTIVATE_GLOBAL_CACHE

const ilGlobalCacheSettings::INI_FIELD_ACTIVATE_GLOBAL_CACHE = 'activate_global_cache'

Definition at line 20 of file class.ilGlobalCacheSettings.php.

◆ INI_FIELD_GLOBAL_CACHE_SERVICE_TYPE

const ilGlobalCacheSettings::INI_FIELD_GLOBAL_CACHE_SERVICE_TYPE = 'global_cache_service_type'

Definition at line 21 of file class.ilGlobalCacheSettings.php.

◆ INI_FIELD_LOG_LEVEL

const ilGlobalCacheSettings::INI_FIELD_LOG_LEVEL = 'log_level'

Definition at line 23 of file class.ilGlobalCacheSettings.php.

◆ INI_HEADER_CACHE

const ilGlobalCacheSettings::INI_HEADER_CACHE = 'cache'

Definition at line 19 of file class.ilGlobalCacheSettings.php.

◆ INI_HEADER_CACHE_ACTIVATED_COMPONENTS

const ilGlobalCacheSettings::INI_HEADER_CACHE_ACTIVATED_COMPONENTS = 'cache_activated_components'

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

◆ LOG_LEVEL_CHATTY

const ilGlobalCacheSettings::LOG_LEVEL_CHATTY = 3

◆ LOG_LEVEL_FORCED

const ilGlobalCacheSettings::LOG_LEVEL_FORCED = -1

Definition at line 14 of file class.ilGlobalCacheSettings.php.

Referenced by HTML_Template_IT\init().

◆ LOG_LEVEL_NONE

const ilGlobalCacheSettings::LOG_LEVEL_NONE = 0

Definition at line 15 of file class.ilGlobalCacheSettings.php.

◆ LOG_LEVEL_NORMAL

const ilGlobalCacheSettings::LOG_LEVEL_NORMAL = 2

Definition at line 17 of file class.ilGlobalCacheSettings.php.

Referenced by ilGlobalCache\generateServiceId().

◆ LOG_LEVEL_SHY

const ilGlobalCacheSettings::LOG_LEVEL_SHY = 1

Definition at line 16 of file class.ilGlobalCacheSettings.php.


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