ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 ()
 
 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 ()
 
 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 193 of file class.ilXcache.php.

References saveValid().

194  {
195  $this->saveValid();
196  }
+ 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 ( )
Returns
bool

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

References $_SERVER.

80  {
81  $_SERVER["PHP_AUTH_USER"] = "xcache";
82  $_SERVER["PHP_AUTH_PW"] = "xcache";
83 
84  xcache_clear_cache(XC_TYPE_VAR, 0);
85 
86  return true;
87  }
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 115 of file class.ilXcache.php.

References ilGlobalCacheService\$active.

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

◆ getInfo()

ilXcache::getInfo ( )
Returns
array

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

References ilGlobalCacheService\isActive().

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

◆ getInstallable()

ilXcache::getInstallable ( )
protected
Returns
bool

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

132  {
133  return function_exists('xcache_set');
134  }

◆ getMemoryLimit()

ilXcache::getMemoryLimit ( )
protected
Returns
int|string

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

152  {
153  return ini_get('xcache.var_size');
154  }

◆ getMinMemory()

ilXcache::getMinMemory ( )
protected
Returns
int

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

161  {
162  return self::MIN_MEMORY;
163  }

◆ readValid()

ilXcache::readValid ( )
protected
Returns
void

set self::$valid_keys from GlobalCache

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

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

Referenced by __construct().

186  {
187  if ($this->isActive() && $this->isInstallable()) {
188  $this->valid_keys = $this->unserialize($this->get('valid_keys'));
189  $this->valid_key_hash = md5(serialize($this->valid_keys));
190  }
191  }
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 170 of file class.ilXcache.php.

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

Referenced by __destruct().

171  {
172  if ($this->isActive()) {
173  if ($this->valid_key_hash != md5(serialize($this->valid_keys))) {
174  $this->set('valid_keys', $this->serialize($this->valid_keys));
175  }
176  }
177  }
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 95 of file class.ilXcache.php.

Referenced by readValid(), and saveValid().

96  {
97  return serialize($value);
98  }
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 106 of file class.ilXcache.php.

Referenced by readValid().

107  {
108  return unserialize($serialized_value);
109  }
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: