ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilGlobalCacheService Class Reference

Class ilGlobalCacheService. More...

+ Inheritance diagram for ilGlobalCacheService:
+ Collaboration diagram for ilGlobalCacheService:

Public Member Functions

 __construct ($service_id, $component)
 __destruct ()
 unserialize ($serialized_value)
 get ($key)
 set ($key, $serialized_value, $ttl=NULL)
 serialize ($value)
 getServiceId ()
 setServiceId ($service_id)
 setValid ($key)
 getComponent ()
 setComponent ($component)
 setInvalid ($key=NULL)
 isValid ($key)
 isActive ()
 isInstallable ()
 returnKey ($key)
 getInfo ()
 getInstallationFailureReason ()
 exists ($key)
 delete ($key)
 flush ()
 setServiceType ($service_type)
 getServiceType ()

Protected Member Functions

 saveValid ()
 readValid ()
 getActive ()
 getInstallable ()
 getMemoryLimit ()
 getMinMemory ()
 checkMemory ()

Protected Attributes

 $current_time = 0
 $valid_keys = array()
 $service_id = ''
 $component = ''
 $service_type = ilGlobalCache::TYPE_STATIC
 $valid_key_hash = ''

Static Protected Attributes

static $active = array()
static $installable = array()

Detailed Description

Class ilGlobalCacheService.

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

Definition at line 9 of file class.ilGlobalCacheService.php.

Constructor & Destructor Documentation

ilGlobalCacheService::__construct (   $service_id,
  $component 
)
Parameters
$service_id
$component

Reimplemented in ilShm, and ilMemcache.

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

References $component, $service_id, checkMemory(), getActive(), getInstallable(), readValid(), setComponent(), and setServiceId().

{
self::$active[get_called_class()] = $this->getActive();
self::$installable[get_called_class()] = ($this->getInstallable() AND $this->checkMemory());
// $this->current_time = time();
$this->readValid();
}

+ Here is the call graph for this function:

ilGlobalCacheService::__destruct ( )

Definition at line 59 of file class.ilGlobalCacheService.php.

References saveValid().

{
$this->saveValid();
}

+ Here is the call graph for this function:

Member Function Documentation

ilGlobalCacheService::checkMemory ( )
protected
Returns
bool

Definition at line 272 of file class.ilGlobalCacheService.php.

References getMemoryLimit(), and getMinMemory().

Referenced by __construct(), and getInstallationFailureReason().

{
$matches = array();
$memory_limit = $this->getMemoryLimit();
if (preg_match('/([0-9]*)([M|K])/uism', $memory_limit, $matches)) {
switch ($matches[2]) {
case 'M':
$memory_limit = $matches[1] * 1024 * 1024; // nnnM -> nnn MB
break;
case 'K':
$memory_limit = $matches[1] * 1024; // nnnK -> nnn KB
break;
}
} else {
$memory_limit = $memory_limit * 1024 * 1024; // nnnM -> nnn MB
}
return ($memory_limit >= $this->getMinMemory() * 1024 * 1024);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilGlobalCacheService::delete (   $key)
abstract
Parameters
$key
Returns
bool

Reimplemented in ilShm, ilMemcache, ilStaticCache, ilApc, and ilXcache.

ilGlobalCacheService::exists (   $key)
abstract
Parameters
$key
Returns
bool

Reimplemented in ilShm, ilMemcache, ilStaticCache, ilApc, and ilXcache.

ilGlobalCacheService::flush ( )
abstract
Returns
mixed

Reimplemented in ilShm, ilMemcache, ilStaticCache, ilApc, and ilXcache.

ilGlobalCacheService::get (   $key)
abstract
Parameters
$key
Returns
mixed

Reimplemented in ilShm, ilMemcache, ilStaticCache, ilApc, and ilXcache.

ilGlobalCacheService::getActive ( )
abstractprotected
Returns
bool

Reimplemented in ilApc, ilMemcache, ilXcache, ilShm, and ilStaticCache.

Referenced by __construct().

+ Here is the caller graph for this function:

ilGlobalCacheService::getComponent ( )
Returns
string

Definition at line 167 of file class.ilGlobalCacheService.php.

References $component.

Referenced by ilStaticCache\delete(), ilStaticCache\exists(), ilStaticCache\get(), ilApc\getInfo(), returnKey(), and ilStaticCache\set().

{
}

+ Here is the caller graph for this function:

ilGlobalCacheService::getInfo ( )
Returns
array

Reimplemented in ilMemcache, ilXcache, and ilApc.

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

{
return array();
}
ilGlobalCacheService::getInstallable ( )
abstractprotected
Returns
bool

Reimplemented in ilApc, ilMemcache, ilXcache, ilShm, and ilStaticCache.

Referenced by __construct(), and getInstallationFailureReason().

+ Here is the caller graph for this function:

ilGlobalCacheService::getInstallationFailureReason ( )
Returns
string

Reimplemented in ilMemcache.

Definition at line 241 of file class.ilGlobalCacheService.php.

References checkMemory(), getInstallable(), and getMinMemory().

{
if (! $this->getInstallable()) {
return 'Not installed';
}
if (! $this->checkMemory()) {
return 'Not enough Cache-Memory, set to at least ' . $this->getMinMemory() . 'M';
}
return 'Unknown reason';
}

+ Here is the call graph for this function:

ilGlobalCacheService::getMemoryLimit ( )
protected
Returns
int

Reimplemented in ilApc, and ilXcache.

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

Referenced by checkMemory().

{
return 9999;
}

+ Here is the caller graph for this function:

ilGlobalCacheService::getMinMemory ( )
protected
Returns
int

Reimplemented in ilApc, and ilXcache.

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

Referenced by checkMemory(), and getInstallationFailureReason().

{
return 0;
}

+ Here is the caller graph for this function:

ilGlobalCacheService::getServiceId ( )
Returns
string

Definition at line 140 of file class.ilGlobalCacheService.php.

References $service_id.

Referenced by ilApc\getInfo(), and returnKey().

{
}

+ Here is the caller graph for this function:

ilGlobalCacheService::getServiceType ( )
Returns
int

Definition at line 325 of file class.ilGlobalCacheService.php.

References $service_type.

{
}
ilGlobalCacheService::isActive ( )
Returns
bool

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

Referenced by ilXcache\getInfo(), readValid(), and saveValid().

{
return self::$active[get_called_class()];
}

+ Here is the caller graph for this function:

ilGlobalCacheService::isInstallable ( )
Returns
bool

Definition at line 213 of file class.ilGlobalCacheService.php.

{
return self::$installable[get_called_class()];
}
ilGlobalCacheService::isValid (   $key)
Parameters
$key
Returns
bool

Definition at line 197 of file class.ilGlobalCacheService.php.

{
return isset($this->valid_keys[$key]);
}
ilGlobalCacheService::readValid ( )
protected
Returns
bool

set self::$valid_keys from GlobalCache

Definition at line 83 of file class.ilGlobalCacheService.php.

References isActive(), serialize(), and unserialize().

Referenced by __construct().

{
if ($this->isActive()) {
$this->valid_keys = $this->unserialize($this->get('valid_keys'));
$this->valid_key_hash = md5(serialize($this->valid_keys));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilGlobalCacheService::returnKey (   $key)
Parameters
$key
Returns
string

Definition at line 223 of file class.ilGlobalCacheService.php.

References getComponent(), and getServiceId().

Referenced by ilXcache\delete(), ilApc\delete(), ilMemcache\delete(), ilXcache\exists(), ilApc\exists(), ilMemcache\exists(), ilXcache\get(), ilApc\get(), ilMemcache\get(), ilXcache\set(), ilApc\set(), and ilMemcache\set().

{
return $str = $this->getServiceId() . '_' . $this->getComponent() . '_' . $key;
return str_replace('/', '_', $str);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilGlobalCacheService::saveValid ( )
protected
Returns
bool

save self::$valid_keys to GlobalCache

Definition at line 69 of file class.ilGlobalCacheService.php.

References isActive(), and serialize().

Referenced by __destruct().

{
if ($this->isActive()) {
if ($this->valid_key_hash != md5(serialize($this->valid_keys))) {
$this->set('valid_keys', $this->serialize($this->valid_keys));
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilGlobalCacheService::serialize (   $value)
abstract
Parameters
$value
Returns
mixed

Reimplemented in ilMemcache, ilShm, ilStaticCache, ilApc, and ilXcache.

Referenced by readValid(), and saveValid().

+ Here is the caller graph for this function:

ilGlobalCacheService::set (   $key,
  $serialized_value,
  $ttl = NULL 
)
abstract
Parameters
$key
$serialized_value
null$ttl
Returns
bool

Reimplemented in ilShm, ilMemcache, ilStaticCache, ilApc, and ilXcache.

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

Definition at line 175 of file class.ilGlobalCacheService.php.

References $component.

Referenced by __construct().

{
$this->component = $component;
}

+ Here is the caller graph for this function:

ilGlobalCacheService::setInvalid (   $key = NULL)
Parameters
null$key

Definition at line 183 of file class.ilGlobalCacheService.php.

{
if ($key) {
unset($this->valid_keys[$key]);
} else {
unset($this->valid_keys);
}
}
ilGlobalCacheService::setServiceId (   $service_id)
Parameters
string$service_id

Definition at line 148 of file class.ilGlobalCacheService.php.

References $service_id.

Referenced by __construct().

{
$this->service_id = $service_id;
}

+ Here is the caller graph for this function:

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

Definition at line 317 of file class.ilGlobalCacheService.php.

References $service_type.

{
$this->service_type = $service_type;
}
ilGlobalCacheService::setValid (   $key)
Parameters
$key
Returns
bool|void

Definition at line 158 of file class.ilGlobalCacheService.php.

{
$this->valid_keys[$key] = true;
// $this->valid_keys[$key] = time();
}
ilGlobalCacheService::unserialize (   $serialized_value)
abstract
Parameters
$serialized_value
Returns
mixed

Reimplemented in ilMemcache, ilShm, ilStaticCache, ilApc, and ilXcache.

Referenced by readValid().

+ Here is the caller graph for this function:

Field Documentation

ilGlobalCacheService::$active = array()
staticprotected

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

Referenced by ilXcache\getActive().

ilGlobalCacheService::$component = ''
protected
ilGlobalCacheService::$current_time = 0
protected

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

ilGlobalCacheService::$installable = array()
staticprotected

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

ilGlobalCacheService::$service_id = ''
protected
ilGlobalCacheService::$service_type = ilGlobalCache::TYPE_STATIC
protected

Definition at line 38 of file class.ilGlobalCacheService.php.

Referenced by getServiceType(), and setServiceType().

ilGlobalCacheService::$valid_key_hash = ''
protected

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

ilGlobalCacheService::$valid_keys = array()
protected

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


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