ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilGlobalCache Class Reference

Class ilGlobalCache. More...

+ Collaboration diagram for ilGlobalCache:

Public Member Functions

 isValid ($key)
 
 isInstallable ()
 
 isCacheServiceInstallable ()
 
 getInstallationFailureReason ()
 
 exists ($key)
 
 set ($key, $value, $ttl=NULL)
 
 get ($key)
 
 delete ($key)
 
 flush ($complete=false)
 
 getInfo ()
 
 setServiceid ($service_id)
 
 getServiceid ()
 
 setComponent ($component)
 
 getComponent ()
 
 setActive ($active)
 
 getActive ()
 
 setServiceType ($service_type)
 
 getServiceType ()
 

Static Public Member Functions

static getInstance ($component)
 
static getAllInstallableTypes ()
 
static getAllTypes ()
 

Data Fields

const MSG = 'Global Cache not active, can not access cache'
 
const ACTIVE = true
 
const TYPE_STATIC = 0
 
const TYPE_XCACHE = 1
 
const TYPE_MEMCACHED = 2
 
const TYPE_APC = 3
 
const TYPE_FALLBACK = self::TYPE_STATIC
 
const COMP_CLNG = 'clng'
 
const COMP_OBJ_DEF = 'obj_def'
 
const COMP_TEMPLATE = 'tpl'
 
const COMP_ILCTRL = 'ilctrl'
 
const COMP_PLUGINS = 'plugins'
 
const COMP_COMPONENT = 'comp'
 
const COMP_RBAC_UA = 'rbac_ua'
 
const COMP_EVENTS = 'events'
 

Protected Member Functions

 __construct ($service_type_id, $component=NULL)
 

Static Protected Member Functions

static generateServiceId ()
 
static lookupServiceName ($type_id)
 

Protected Attributes

 $global_cache
 
 $service_id = ''
 
 $component
 
 $active = true
 
 $service_type = ilGlobalCache::TYPE_STATIC
 

Static Protected Attributes

static $types
 
static $active_components
 
static $type_per_component = array()
 
static $unique_service_id = NULL
 
static $instances
 

Detailed Description

Class ilGlobalCache.

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

Definition at line 13 of file class.ilGlobalCache.php.

Constructor & Destructor Documentation

◆ __construct()

ilGlobalCache::__construct (   $service_type_id,
  $component = NULL 
)
protected
Parameters
$service_type_id
$component

Definition at line 186 of file class.ilGlobalCache.php.

References $component, getComponent(), getServiceid(), setActive(), setComponent(), and setServiceid().

186  {
187  $this->setComponent($component);
188  $this->setServiceid(self::generateServiceId());
189  $this->setActive(in_array($component, self::$active_components));
190  $serviceName = self::lookupServiceName($service_type_id);
191  $this->global_cache = new $serviceName($this->getServiceid(), $this->getComponent());
192  $this->global_cache->setServiceType($service_type_id);
193  }
setServiceid($service_id)
setComponent($component)
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilGlobalCache::delete (   $key)
Parameters
$key
Exceptions
RuntimeException
Returns
bool

Definition at line 344 of file class.ilGlobalCache.php.

344  {
345  if (!$this->isActive()) {
346 
347  return false;
348  throw new RuntimeException(self::MSG);
349  }
350 
351  return $this->global_cache->delete($key);
352  }

◆ exists()

ilGlobalCache::exists (   $key)
Parameters
$key
Exceptions
RuntimeException
Returns
bool

Definition at line 286 of file class.ilGlobalCache.php.

286  {
287  if (!$this->global_cache->isActive()) {
288  return false;
289  }
290 
291  return $this->global_cache->exists($key);
292  }

◆ flush()

ilGlobalCache::flush (   $complete = false)
Parameters
bool$complete
Returns
bool
Exceptions
RuntimeException

Definition at line 361 of file class.ilGlobalCache.php.

361  {
362  if ($this->global_cache->isActive()) {
363  if ($complete) {
364  return $this->global_cache->flush();
365  } else {
366  $this->global_cache->setInvalid();
367  }
368  }
369 
370  return false;
371  }

◆ generateServiceId()

static ilGlobalCache::generateServiceId ( )
staticprotected
Returns
string

Definition at line 130 of file class.ilGlobalCache.php.

130  {
131  if (!isset(self::$unique_service_id)) {
132  self::$unique_service_id = substr(md5('il_' . CLIENT_ID), 0, 6);
133  }
134 
135  return self::$unique_service_id;
136  }

◆ get()

ilGlobalCache::get (   $key)
Parameters
$key
Exceptions
RuntimeException
Returns
mixed

Definition at line 319 of file class.ilGlobalCache.php.

319  {
320  if (!$this->isActive()) {
321  return false;
322  }
323  $unserialized_return = $this->global_cache->unserialize($this->global_cache->get($key));
324  if ($unserialized_return) {
325 
326  if ($this->global_cache->isValid($key)) {
327 
328  return $unserialized_return;
329  } else {
330  // var_dump($key); // FSX
331  }
332  }
333 
334  return NULL;
335  }

◆ getActive()

ilGlobalCache::getActive ( )
Returns
boolean

Definition at line 422 of file class.ilGlobalCache.php.

References $active.

Referenced by lookupServiceName().

422  {
423  return $this->active;
424  }
+ Here is the caller graph for this function:

◆ getAllInstallableTypes()

static ilGlobalCache::getAllInstallableTypes ( )
static
Returns
ilGlobalCache[]

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

References $types.

156  {
157  $types = array();
158  foreach (self::getAllTypes() as $type) {
159  if ($type->isCacheServiceInstallable()) {
160  $types[] = $type;
161  }
162  }
163 
164  return $types;
165  }

◆ getAllTypes()

static ilGlobalCache::getAllTypes ( )
static
Returns
ilGlobalCache[]

Definition at line 171 of file class.ilGlobalCache.php.

References $types.

Referenced by ilSetupGUI\displayDatabase().

171  {
172  $types = array();
173  foreach (self::$types as $type) {
174  $obj = new self($type);
175  $types[$type] = $obj;
176  }
177 
178  return $types;
179  }
+ Here is the caller graph for this function:

◆ getComponent()

ilGlobalCache::getComponent ( )
Returns
string

Definition at line 406 of file class.ilGlobalCache.php.

References $component.

Referenced by __construct().

406  {
407  return $this->component;
408  }
+ Here is the caller graph for this function:

◆ getInfo()

ilGlobalCache::getInfo ( )

Definition at line 374 of file class.ilGlobalCache.php.

374  {
375  return $this->global_cache->getInfo();
376  }

◆ getInstallationFailureReason()

ilGlobalCache::getInstallationFailureReason ( )
Returns
string

Definition at line 275 of file class.ilGlobalCache.php.

275  {
276  return $this->global_cache->getInstallationFailureReason();
277  }

◆ getInstance()

static ilGlobalCache::getInstance (   $component)
static
Parameters
null$component
Returns
ilGlobalCache

Definition at line 115 of file class.ilGlobalCache.php.

References $component, and $service_type.

Referenced by ilGlobalCacheDBLayer\__construct(), ilCachedCtrl\__construct(), ilCachedComponentData\__construct(), ilCachedComponentData\__destruct(), ilCachedCtrl\flush(), ilCachedComponentData\flush(), ilGlobalCacheQueryWrapper\get(), ilCachedCtrl\getInstance(), ilCachedComponentData\getInstance(), ilAppEventHandler\initListeners(), ilCachedCtrl\isActive(), and ilObjectDefinition\readDefinitionData().

115  {
116  if (!isset(self::$instances[$component])) {
117  $service_type = self::getComponentType($component);
118  $ilGlobalCache = new self($service_type, $component);
119 
120  self::$instances[$component] = $ilGlobalCache;
121  }
122 
123  return self::$instances[$component];
124  }
+ Here is the caller graph for this function:

◆ getServiceid()

ilGlobalCache::getServiceid ( )
Returns
string

Definition at line 390 of file class.ilGlobalCache.php.

References $service_id.

Referenced by __construct().

390  {
391  return $this->service_id;
392  }
+ Here is the caller graph for this function:

◆ getServiceType()

ilGlobalCache::getServiceType ( )
Returns
int

Definition at line 438 of file class.ilGlobalCache.php.

438  {
439  return $this->global_cache->getServiceType();
440  }

◆ isCacheServiceInstallable()

ilGlobalCache::isCacheServiceInstallable ( )
Returns
bool

Definition at line 267 of file class.ilGlobalCache.php.

267  {
268  return $this->global_cache->isInstallable();
269  }

◆ isInstallable()

ilGlobalCache::isInstallable ( )
Returns
bool

Definition at line 259 of file class.ilGlobalCache.php.

259  {
260  return count(self::getAllInstallableTypes()) > 0;
261  }

◆ isValid()

ilGlobalCache::isValid (   $key)
Parameters
$key
Returns
bool

Definition at line 251 of file class.ilGlobalCache.php.

251  {
252  return $this->global_cache->isValid($key);
253  }

◆ lookupServiceName()

static ilGlobalCache::lookupServiceName (   $type_id)
staticprotected
Parameters
$type_id
Returns
string

Definition at line 201 of file class.ilGlobalCache.php.

References getActive().

201  {
202  switch ($type_id) {
203  case self::TYPE_APC:
204  return 'ilApc';
205  break;
206  case self::TYPE_MEMCACHED:
207  return 'ilMemcache';
208  break;
209  case self::TYPE_XCACHE:
210  return 'ilXcache';
211  break;
212  default:
213  return 'ilStaticCache';
214  break;
215  }
216  }
+ Here is the call graph for this function:

◆ set()

ilGlobalCache::set (   $key,
  $value,
  $ttl = NULL 
)
Parameters
$key
$value
null$ttl
Exceptions
RuntimeException
Returns
bool

Definition at line 303 of file class.ilGlobalCache.php.

303  {
304  if (!$this->isActive()) {
305  return false;
306  }
307  $this->global_cache->setValid($key);
308 
309  return $this->global_cache->set($key, $this->global_cache->serialize($value), $ttl);
310  }

◆ setActive()

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

Definition at line 414 of file class.ilGlobalCache.php.

References $active.

Referenced by __construct().

414  {
415  $this->active = $active;
416  }
+ Here is the caller graph for this function:

◆ setComponent()

ilGlobalCache::setComponent (   $component)
Parameters
string$component

Definition at line 398 of file class.ilGlobalCache.php.

References $component.

Referenced by __construct().

398  {
399  $this->component = $component;
400  }
+ Here is the caller graph for this function:

◆ setServiceid()

ilGlobalCache::setServiceid (   $service_id)
Parameters
string$service_id

Definition at line 382 of file class.ilGlobalCache.php.

References $service_id.

Referenced by __construct().

382  {
383  $this->service_id = $service_id;
384  }
+ Here is the caller graph for this function:

◆ setServiceType()

ilGlobalCache::setServiceType (   $service_type)
Parameters
int$service_type

Definition at line 430 of file class.ilGlobalCache.php.

References $service_type.

430  {
431  $this->global_cache->setServiceType($service_type);
432  }

Field Documentation

◆ $active

ilGlobalCache::$active = true
protected

Definition at line 78 of file class.ilGlobalCache.php.

Referenced by getActive(), and setActive().

◆ $active_components

ilGlobalCache::$active_components
staticprotected
Initial value:
= array(
self::COMP_CLNG,
self::COMP_OBJ_DEF,
self::COMP_ILCTRL,
self::COMP_COMPONENT,
self::COMP_TEMPLATE,
self::COMP_EVENTS,
)

Definition at line 42 of file class.ilGlobalCache.php.

◆ $component

ilGlobalCache::$component
protected

Definition at line 74 of file class.ilGlobalCache.php.

Referenced by __construct(), getComponent(), getInstance(), and setComponent().

◆ $global_cache

ilGlobalCache::$global_cache
protected

Definition at line 66 of file class.ilGlobalCache.php.

◆ $instances

ilGlobalCache::$instances
staticprotected

Definition at line 62 of file class.ilGlobalCache.php.

◆ $service_id

ilGlobalCache::$service_id = ''
protected

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

Referenced by getServiceid(), and setServiceid().

◆ $service_type

ilGlobalCache::$service_type = ilGlobalCache::TYPE_STATIC
protected

Definition at line 82 of file class.ilGlobalCache.php.

Referenced by getInstance(), and setServiceType().

◆ $type_per_component

ilGlobalCache::$type_per_component = array()
staticprotected

Definition at line 54 of file class.ilGlobalCache.php.

◆ $types

ilGlobalCache::$types
staticprotected
Initial value:
= array(
self::TYPE_APC,
self::TYPE_STATIC
)

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

Referenced by getAllInstallableTypes(), and getAllTypes().

◆ $unique_service_id

ilGlobalCache::$unique_service_id = NULL
staticprotected

Definition at line 58 of file class.ilGlobalCache.php.

◆ ACTIVE

const ilGlobalCache::ACTIVE = true

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

◆ COMP_CLNG

const ilGlobalCache::COMP_CLNG = 'clng'

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

◆ COMP_COMPONENT

◆ COMP_EVENTS

const ilGlobalCache::COMP_EVENTS = 'events'

Definition at line 29 of file class.ilGlobalCache.php.

Referenced by ilAppEventHandler\initListeners().

◆ COMP_ILCTRL

const ilGlobalCache::COMP_ILCTRL = 'ilctrl'

◆ COMP_OBJ_DEF

const ilGlobalCache::COMP_OBJ_DEF = 'obj_def'

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

◆ COMP_PLUGINS

const ilGlobalCache::COMP_PLUGINS = 'plugins'

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

◆ COMP_RBAC_UA

const ilGlobalCache::COMP_RBAC_UA = 'rbac_ua'

Definition at line 28 of file class.ilGlobalCache.php.

◆ COMP_TEMPLATE

const ilGlobalCache::COMP_TEMPLATE = 'tpl'

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

◆ MSG

const ilGlobalCache::MSG = 'Global Cache not active, can not access cache'

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

◆ TYPE_APC

const ilGlobalCache::TYPE_APC = 3

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

◆ TYPE_FALLBACK

const ilGlobalCache::TYPE_FALLBACK = self::TYPE_STATIC

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

◆ TYPE_MEMCACHED

const ilGlobalCache::TYPE_MEMCACHED = 2

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

◆ TYPE_STATIC

const ilGlobalCache::TYPE_STATIC = 0

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

◆ TYPE_XCACHE

const ilGlobalCache::TYPE_XCACHE = 1

Definition at line 18 of file class.ilGlobalCache.php.


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