ILIAS  release_8 Revision v8.24
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 (int $service)
 
 getActivatedComponents ()
 
 setActivatedComponents (array $activated_components)
 
 isActive ()
 
 setActive (bool $active)
 
 getLogLevel ()
 
 setLogLevel (int $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 (int $level)
 

Protected Attributes

int $service = ilGlobalCache::TYPE_STATIC
 
array $activated_components = []
 
bool $active = false
 
int $log_level = self::LOG_LEVEL_NONE
 
array $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 26 of file class.ilGlobalCacheSettings.php.

Member Function Documentation

◆ __toString()

ilGlobalCacheSettings::__toString ( )

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

232 : string
233 {
234 $service = 'Service: ' . ($this->getService(
236 $this->getService()
237 ) : 'none');
238 $activated = 'Activated Components: ' . implode(
239 ', ',
241 );
242 $log_level = 'Log Level: ' . $this->getLogLevelName();
243
244 return implode("\n", ['', '', $service, $activated, $log_level, '']);
245 }
static lookupServiceClassName(int $service_type)

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

+ Here is the call graph for this function:

◆ activateAll()

ilGlobalCacheSettings::activateAll ( )

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

144 : void
145 {
146 foreach (ilGlobalCache::getAvailableComponents() as $comp) {
147 $this->addActivatedComponent($comp);
148 }
149 }
static getAvailableComponents()

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

+ Here is the call graph for this function:

◆ addActivatedComponent()

ilGlobalCacheSettings::addActivatedComponent (   $component)
Parameters
mixed$component

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

154 : void
155 {
156 $this->activated_components[] = $component;
157 $this->activated_components = array_unique($this->activated_components);
158 }

Referenced by activateAll(), and readFromIniFile().

+ Here is the caller graph for this function:

◆ addMemcachedNode()

ilGlobalCacheSettings::addMemcachedNode ( ilMemcacheServer  $node_id)

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

264 : void
265 {
266 $this->memcached_nodes[] = $node_id;
267 }

◆ areAllComponentActivated()

ilGlobalCacheSettings::areAllComponentActivated ( )

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

173 : bool
174 {
175 return count($this->activated_components) === count(
177 );
178 }

References ilGlobalCache\getAvailableComponents().

+ Here is the call graph for this function:

◆ checkIniHeader()

ilGlobalCacheSettings::checkIniHeader ( ilIniFile  $ilIniFile)
protected

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

210 : void
211 {
212 if (!$ilIniFile->readGroup(self::INI_HEADER_CACHE)) {
213 $ilIniFile->addGroup(self::INI_HEADER_CACHE);
214 }
215 if (!$ilIniFile->readGroup(
216 self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS
217 )) {
218 $ilIniFile->addGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
219 }
220 }

Referenced by readFromIniFile().

+ Here is the caller graph for this function:

◆ getActivatedComponents()

ilGlobalCacheSettings::getActivatedComponents ( )

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

190 : array
191 {
193 }

References $activated_components.

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

+ Here is the caller graph for this function:

◆ getLogLevel()

ilGlobalCacheSettings::getLogLevel ( )

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

222 : int
223 {
224 return $this->log_level;
225 }

References $log_level.

Referenced by getLogLevelName(), and writeToIniFile().

+ Here is the caller graph for this function:

◆ getLogLevelName()

ilGlobalCacheSettings::getLogLevelName ( )
protected

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

247 : string
248 {
249 return $this->lookupLogLevelName($this->getLogLevel());
250 }

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 ( )

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

269 : array
270 {
272 }

References $memcached_nodes.

◆ getService()

ilGlobalCacheSettings::getService ( )

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

180 : int
181 {
182 return $this->service;
183 }

References $service.

Referenced by __toString(), and writeToIniFile().

+ Here is the caller graph for this function:

◆ isActive()

ilGlobalCacheSettings::isActive ( )

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

200 : bool
201 {
202 return $this->active;
203 }

References $active.

Referenced by readFromIniFile(), and writeToIniFile().

+ Here is the caller graph for this function:

◆ isComponentActivated()

ilGlobalCacheSettings::isComponentActivated (   $component)
Parameters
mixed$component

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

168 : bool
169 {
170 return in_array($component, $this->activated_components);
171 }

Referenced by writeToIniFile().

+ Here is the caller graph for this function:

◆ lookupLogLevelName()

ilGlobalCacheSettings::lookupLogLevelName ( int  $level)
protected

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

252 : string
253 {
254 $r = new ReflectionClass($this);
255 foreach ($r->getConstants() as $k => $v) {
256 if (strpos($k, 'LOG_LEVEL') === 0 && $v == $level) {
257 return $k;
258 }
259 }
260
261 return '';
262 }

Referenced by getLogLevelName().

+ Here is the caller graph for this function:

◆ readFromIniFile()

ilGlobalCacheSettings::readFromIniFile ( ilIniFile  $ilIniFile)

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

77 : void
78 {
79 $this->checkIniHeader($ilIniFile);
80 $this->setActive(
81 $ilIniFile->readVariable(
82 self::INI_HEADER_CACHE,
83 self::INI_FIELD_ACTIVATE_GLOBAL_CACHE
84 )
85 );
86 $this->setService(
87 (int)$ilIniFile->readVariable(
88 self::INI_HEADER_CACHE,
89 self::INI_FIELD_GLOBAL_CACHE_SERVICE_TYPE
90 )
91 );
92 $this->setLogLevel(
93 (int) $ilIniFile->readVariable(
94 self::INI_HEADER_CACHE,
95 self::INI_FIELD_LOG_LEVEL
96 )
97 );
98 if (!$this->isActive()) {
100 } else {
101 $cache_components = $ilIniFile->readGroup(
102 self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS
103 );
104 if (is_array($cache_components)) {
105 foreach ($cache_components as $comp => $v) {
106 if ($v) {
107 $this->addActivatedComponent($comp);
108 }
109 }
110 }
111 }
112 }
checkIniHeader(ilIniFile $ilIniFile)

References addActivatedComponent(), checkIniHeader(), isActive(), resetActivatedComponents(), setActive(), setLogLevel(), and setService().

+ Here is the call graph for this function:

◆ resetActivatedComponents()

ilGlobalCacheSettings::resetActivatedComponents ( )

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

160 : void
161 {
162 $this->activated_components = [];
163 }

Referenced by readFromIniFile().

+ Here is the caller graph for this function:

◆ setActivatedComponents()

ilGlobalCacheSettings::setActivatedComponents ( array  $activated_components)

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

195 : void
196 {
197 $this->activated_components = $activated_components;
198 }

References $activated_components.

◆ setActive()

ilGlobalCacheSettings::setActive ( bool  $active)

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

205 : void
206 {
207 $this->active = $active;
208 }

References $active.

Referenced by readFromIniFile().

+ Here is the caller graph for this function:

◆ setLogLevel()

ilGlobalCacheSettings::setLogLevel ( int  $log_level)

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

227 : void
228 {
229 $this->log_level = $log_level;
230 }

References $log_level.

Referenced by readFromIniFile().

+ Here is the caller graph for this function:

◆ setService()

ilGlobalCacheSettings::setService ( int  $service)

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

185 : void
186 {
187 $this->service = $service;
188 }

References $service.

Referenced by readFromIniFile().

+ Here is the caller graph for this function:

◆ writeToIniFile()

ilGlobalCacheSettings::writeToIniFile ( ilIniFile  $ilIniFile)

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

114 : bool
115 {
116 $ilIniFile->setVariable(
117 self::INI_HEADER_CACHE,
118 self::INI_FIELD_ACTIVATE_GLOBAL_CACHE,
119 $this->isActive() ? '1' : '0'
120 );
121 $ilIniFile->setVariable(
122 self::INI_HEADER_CACHE,
123 self::INI_FIELD_GLOBAL_CACHE_SERVICE_TYPE,
124 $this->getService()
125 );
126 $ilIniFile->setVariable(
127 self::INI_HEADER_CACHE,
128 self::INI_FIELD_LOG_LEVEL,
129 $this->getLogLevel()
130 );
131
132 $ilIniFile->removeGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
133 $ilIniFile->addGroup(self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS);
134 foreach (ilGlobalCache::getAvailableComponents() as $comp) {
135 $ilIniFile->setVariable(
136 self::INI_HEADER_CACHE_ACTIVATED_COMPONENTS,
137 $comp,
138 $this->isComponentActivated($comp) ? '1' : '0'
139 );
140 }
141 return $ilIniFile->write();
142 }
write()
save ini-file-data to filesystem

References ilGlobalCache\getAvailableComponents(), getLogLevel(), getService(), isActive(), isComponentActivated(), and ilIniFile\write().

+ Here is the call graph for this function:

Field Documentation

◆ $activated_components

array ilGlobalCacheSettings::$activated_components = []
protected

◆ $active

bool ilGlobalCacheSettings::$active = false
protected

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

Referenced by isActive(), and setActive().

◆ $log_level

int ilGlobalCacheSettings::$log_level = self::LOG_LEVEL_NONE
protected

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

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

◆ $memcached_nodes

array ilGlobalCacheSettings::$memcached_nodes = []
protected

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

Referenced by getMemcachedNodes().

◆ $service

int ilGlobalCacheSettings::$service = ilGlobalCache::TYPE_STATIC
protected

Definition at line 68 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 55 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 59 of file class.ilGlobalCacheSettings.php.

◆ INI_FIELD_LOG_LEVEL

const ilGlobalCacheSettings::INI_FIELD_LOG_LEVEL = 'log_level'

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

◆ INI_HEADER_CACHE

const ilGlobalCacheSettings::INI_HEADER_CACHE = 'cache'

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

◆ INI_HEADER_CACHE_ACTIVATED_COMPONENTS

const ilGlobalCacheSettings::INI_HEADER_CACHE_ACTIVATED_COMPONENTS = 'cache_activated_components'

Definition at line 63 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 31 of file class.ilGlobalCacheSettings.php.

Referenced by HTML_Template_IT\init().

◆ LOG_LEVEL_NONE

const ilGlobalCacheSettings::LOG_LEVEL_NONE = 0

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

◆ LOG_LEVEL_NORMAL

const ilGlobalCacheSettings::LOG_LEVEL_NORMAL = 2

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

◆ LOG_LEVEL_SHY

const ilGlobalCacheSettings::LOG_LEVEL_SHY = 1

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


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