ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilXcache Class Reference

Class ilXcache. More...

+ Inheritance diagram for ilXcache:
+ Collaboration diagram for ilXcache:

Public Member Functions

 __construct ($serviceId, $component)
 ilXcache constructor. More...
 
 exists ($key)
 
 set ($key, $serialized_value, $ttl=null)
 
 get ($key)
 
 delete ($key)
 
 flush ($complete=false)
 
 serialize ($value)
 
 unserialize ($serialized_value)
 
 getInfo ()
 
 __destruct ()
 
- Public Member Functions inherited from ilGlobalCacheService
 __construct ($service_id, $component)
 
 unserialize ($serialized_value)
 
 get ($key)
 
 set ($key, $serialized_value, $ttl=null)
 
 serialize ($value)
 
 getServiceId ()
 
 setServiceId ($service_id)
 
 getComponent ()
 
 setComponent ($component)
 
 isActive ()
 
 isInstallable ()
 
 returnKey ($key)
 
 getInfo ()
 
 getInstallationFailureReason ()
 
 exists ($key)
 
 delete ($key)
 
 flush ($complete=false)
 
 setServiceType ($service_type)
 
 getServiceType ()
 
 setValid ($key)
 Declare a key as valid. More...
 
 setInvalid ($key=null)
 Set the key as invalid. More...
 
 isValid ($key)
 Checks whether the cache key is valid or not. More...
 

Data Fields

const MIN_MEMORY = 32
 

Protected Member Functions

 getActive ()
 
 getInstallable ()
 
 getMemoryLimit ()
 
 getMinMemory ()
 
 saveValid ()
 
 readValid ()
 
- Protected Member Functions inherited from ilGlobalCacheService
 getActive ()
 
 getInstallable ()
 
 getMemoryLimit ()
 
 getMinMemory ()
 
 checkMemory ()
 

Additional Inherited Members

- Protected Attributes inherited from ilGlobalCacheService
 $current_time = 0
 
 $valid_keys = array()
 
 $service_id = ''
 
 $component = ''
 
 $service_type = ilGlobalCache::TYPE_STATIC
 
 $valid_key_hash = ''
 
- Static Protected Attributes inherited from ilGlobalCacheService
static $active = array()
 
static $installable = array()
 

Detailed Description

Class ilXcache.

Concrete XCache implementation.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilXcache::__construct (   $serviceId,
  $component 
)

ilXcache constructor.

Parameters
$serviceId
$component

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

References ilGlobalCacheService\$component, and readValid().

24  {
25  parent::__construct($serviceId, $component);
26  $this->readValid();
27  }
+ Here is the call graph for this function:

◆ __destruct()

ilXcache::__destruct ( )

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

References saveValid().

196  {
197  $this->saveValid();
198  }
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilXcache::delete (   $key)
Parameters
$key
Returns
bool

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

References $key, and ilGlobalCacheService\returnKey().

71  {
72  return xcache_unset($this->returnKey($key));
73  }
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ exists()

ilXcache::exists (   $key)
Parameters
$key
Returns
bool

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

References $key, and ilGlobalCacheService\returnKey().

36  {
37  return xcache_isset($this->returnKey($key));
38  }
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ flush()

ilXcache::flush (   $complete = false)
Parameters
bool$complete
Returns
bool

Definition at line 81 of file class.ilXcache.php.

References $_SERVER.

82  {
83  $_SERVER["PHP_AUTH_USER"] = "xcache";
84  $_SERVER["PHP_AUTH_PW"] = "xcache";
85 
86  xcache_clear_cache(XC_TYPE_VAR, 0);
87 
88  return true;
89  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

◆ get()

ilXcache::get (   $key)
Parameters
$key
Returns
mixed

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

References $key, and ilGlobalCacheService\returnKey().

60  {
61  return xcache_get($this->returnKey($key));
62  }
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ getActive()

ilXcache::getActive ( )
protected
Returns
bool

Definition at line 117 of file class.ilXcache.php.

References ilGlobalCacheService\$active.

118  {
119  $function_exists = function_exists('xcache_set');
120  $var_size = ini_get('xcache.var_size') != '0M';
121  $var_count = ini_get('xcache.var_count') > 0;
122  $api = (php_sapi_name() !== 'cli');
123 
124  $active = $function_exists and $var_size and $var_count and $api;
125 
126  return $active;
127  }

◆ getInfo()

ilXcache::getInfo ( )
Returns
array

Definition at line 142 of file class.ilXcache.php.

References ilGlobalCacheService\isActive().

143  {
144  if ($this->isActive()) {
145  return xcache_info(XC_TYPE_VAR, 0);
146  }
147  }
+ Here is the call graph for this function:

◆ getInstallable()

ilXcache::getInstallable ( )
protected
Returns
bool

Definition at line 133 of file class.ilXcache.php.

134  {
135  return function_exists('xcache_set');
136  }

◆ getMemoryLimit()

ilXcache::getMemoryLimit ( )
protected
Returns
int|string

Definition at line 153 of file class.ilXcache.php.

154  {
155  return ini_get('xcache.var_size');
156  }

◆ getMinMemory()

ilXcache::getMinMemory ( )
protected
Returns
int

Definition at line 162 of file class.ilXcache.php.

163  {
164  return self::MIN_MEMORY;
165  }

◆ readValid()

ilXcache::readValid ( )
protected
Returns
void

set self::$valid_keys from GlobalCache

Definition at line 187 of file class.ilXcache.php.

References ilGlobalCacheService\isActive(), ilGlobalCacheService\isInstallable(), serialize(), and unserialize().

Referenced by __construct().

188  {
189  if ($this->isActive() && $this->isInstallable()) {
190  $this->valid_keys = $this->unserialize($this->get('valid_keys'));
191  $this->valid_key_hash = md5(serialize($this->valid_keys));
192  }
193  }
serialize($value)
unserialize($serialized_value)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveValid()

ilXcache::saveValid ( )
protected
Returns
void

save self::$valid_keys to GlobalCache

Definition at line 172 of file class.ilXcache.php.

References ilGlobalCacheService\isActive(), and serialize().

Referenced by __destruct().

173  {
174  if ($this->isActive()) {
175  if ($this->valid_key_hash != md5(serialize($this->valid_keys))) {
176  $this->set('valid_keys', $this->serialize($this->valid_keys));
177  }
178  }
179  }
serialize($value)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

ilXcache::serialize (   $value)
Parameters
$value
Returns
mixed

Definition at line 97 of file class.ilXcache.php.

Referenced by readValid(), and saveValid().

98  {
99  return serialize($value);
100  }
serialize($value)
+ Here is the caller graph for this function:

◆ set()

ilXcache::set (   $key,
  $serialized_value,
  $ttl = null 
)
Parameters
$key
$serialized_value
null$ttl
Returns
bool

Definition at line 48 of file class.ilXcache.php.

References $key, and ilGlobalCacheService\returnKey().

49  {
50  return xcache_set($this->returnKey($key), $serialized_value, $ttl);
51  }
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ unserialize()

ilXcache::unserialize (   $serialized_value)
Parameters
$serialized_value
Returns
mixed

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

Referenced by readValid().

109  {
110  return unserialize($serialized_value);
111  }
unserialize($serialized_value)
+ Here is the caller graph for this function:

Field Documentation

◆ MIN_MEMORY

const ilXcache::MIN_MEMORY = 32

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


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