ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups 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

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(), lookupServiceName(), setActive(), setComponent(), and setServiceid().

{
$this->setServiceid(self::generateServiceId());
$this->setActive(in_array($component, self::$active_components));
$serviceName = self::lookupServiceName($service_type_id);
$this->global_cache = new $serviceName($this->getServiceid(), $this->getComponent());
$this->global_cache->setServiceType($service_type_id);
}

+ Here is the call graph for this function:

Member Function Documentation

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

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

{
if (!$this->isActive()) {
return false;
throw new RuntimeException(self::MSG);
}
return $this->global_cache->delete($key);
}
ilGlobalCache::exists (   $key)
Parameters
$key
Exceptions
RuntimeException
Returns
bool

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

{
if (!$this->global_cache->isActive()) {
return false;
}
return $this->global_cache->exists($key);
}
ilGlobalCache::flush (   $complete = false)
Parameters
bool$complete
Returns
bool
Exceptions
RuntimeException

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

{
if ($this->global_cache->isActive()) {
if ($complete) {
return $this->global_cache->flush();
} else {
$this->global_cache->setInvalid();
}
}
return false;
}
static ilGlobalCache::generateServiceId ( )
staticprotected
Returns
string

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

References $unique_service_id.

{
if (!isset(self::$unique_service_id)) {
self::$unique_service_id = substr(md5('il_' . CLIENT_ID), 0, 6);
}
}
ilGlobalCache::get (   $key)
Parameters
$key
Exceptions
RuntimeException
Returns
mixed

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

{
if (!$this->isActive()) {
return false;
}
$unserialized_return = $this->global_cache->unserialize($this->global_cache->get($key));
if ($unserialized_return) {
if ($this->global_cache->isValid($key)) {
return $unserialized_return;
} else {
// var_dump($key); // FSX
}
}
return NULL;
}
ilGlobalCache::getActive ( )
Returns
boolean

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

References $active.

{
return $this->active;
}
static ilGlobalCache::getAllInstallableTypes ( )
static
Returns
ilGlobalCache[]

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

References $types.

{
$types = array();
foreach (self::getAllTypes() as $type) {
if ($type->isCacheServiceInstallable()) {
$types[] = $type;
}
}
return $types;
}
static ilGlobalCache::getAllTypes ( )
static
Returns
ilGlobalCache[]

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

References $types.

{
$types = array();
foreach (self::$types as $type) {
$obj = new self($type);
$types[$type] = $obj;
}
return $types;
}
ilGlobalCache::getComponent ( )
Returns
string

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

References $component.

Referenced by __construct().

{
}

+ Here is the caller graph for this function:

ilGlobalCache::getInfo ( )

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

{
return $this->global_cache->getInfo();
}
ilGlobalCache::getInstallationFailureReason ( )
Returns
string

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

{
return $this->global_cache->getInstallationFailureReason();
}
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 ilGlobalCacheQueryWrapper\get(), ilAppEventHandler\initListeners(), and ilObjectDefinition\readDefinitionData().

{
if (!isset(self::$instances[$component])) {
$service_type = self::getComponentType($component);
$ilGlobalCache = new self($service_type, $component);
self::$instances[$component] = $ilGlobalCache;
}
return self::$instances[$component];
}

+ Here is the caller graph for this function:

ilGlobalCache::getServiceid ( )
Returns
string

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

References $service_id.

Referenced by __construct().

{
}

+ Here is the caller graph for this function:

ilGlobalCache::getServiceType ( )
Returns
int

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

{
return $this->global_cache->getServiceType();
}
ilGlobalCache::isCacheServiceInstallable ( )
Returns
bool

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

{
return $this->global_cache->isInstallable();
}
ilGlobalCache::isInstallable ( )
Returns
bool

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

{
return count(self::getAllInstallableTypes()) > 0;
}
ilGlobalCache::isValid (   $key)
Parameters
$key
Returns
bool

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

{
return $this->global_cache->isValid($key);
}
static ilGlobalCache::lookupServiceName (   $type_id)
staticprotected
Parameters
$type_id
Returns
string

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

Referenced by __construct().

{
switch ($type_id) {
case self::TYPE_APC:
return 'ilApc';
break;
case self::TYPE_MEMCACHED:
return 'ilMemcache';
break;
case self::TYPE_XCACHE:
return 'ilXcache';
break;
default:
return 'ilStaticCache';
break;
}
}

+ Here is the caller graph for this function:

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

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

{
if (!$this->isActive()) {
return false;
}
$this->global_cache->setValid($key);
return $this->global_cache->set($key, $this->global_cache->serialize($value), $ttl);
}
ilGlobalCache::setActive (   $active)
Parameters
boolean$active

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

References $active.

Referenced by __construct().

{
$this->active = $active;
}

+ Here is the caller graph for this function:

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

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

References $component.

Referenced by __construct().

{
$this->component = $component;
}

+ Here is the caller graph for this function:

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

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

References $service_id.

Referenced by __construct().

{
$this->service_id = $service_id;
}

+ Here is the caller graph for this function:

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

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

References $service_type.

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

Field Documentation

ilGlobalCache::$active = true
protected

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

Referenced by getActive(), and setActive().

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.

ilGlobalCache::$component
protected

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

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

ilGlobalCache::$global_cache
protected

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

ilGlobalCache::$instances
staticprotected

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

ilGlobalCache::$service_id = ''
protected

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

Referenced by getServiceid(), and setServiceid().

ilGlobalCache::$service_type = ilGlobalCache::TYPE_STATIC
protected

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

Referenced by getInstance(), and setServiceType().

ilGlobalCache::$type_per_component = array()
staticprotected

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

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

ilGlobalCache::$unique_service_id = NULL
staticprotected

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

Referenced by generateServiceId().

const ilGlobalCache::ACTIVE = true

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

const ilGlobalCache::COMP_CLNG = 'clng'

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

const ilGlobalCache::COMP_EVENTS = 'events'

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

Referenced by ilAppEventHandler\initListeners().

const ilGlobalCache::COMP_ILCTRL = 'ilctrl'
const ilGlobalCache::COMP_OBJ_DEF = 'obj_def'

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

const ilGlobalCache::COMP_PLUGINS = 'plugins'

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

const ilGlobalCache::COMP_RBAC_UA = 'rbac_ua'

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

const ilGlobalCache::COMP_TEMPLATE = 'tpl'

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

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

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

const ilGlobalCache::TYPE_APC = 3

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

const ilGlobalCache::TYPE_FALLBACK = self::TYPE_STATIC

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

const ilGlobalCache::TYPE_MEMCACHED = 2

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

const ilGlobalCache::TYPE_STATIC = 0

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

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: