ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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().

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

◆ __destruct()

ilXcache::__destruct ( )

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

References saveValid().

178  {
179  $this->saveValid();
180  }
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

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

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

References ilGlobalCacheService\returnKey().

66  {
67  return xcache_unset($this->returnKey($key));
68  }
+ Here is the call graph for this function:

◆ exists()

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

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

References ilGlobalCacheService\returnKey().

34  {
35  return xcache_isset($this->returnKey($key));
36  }
+ Here is the call graph for this function:

◆ flush()

ilXcache::flush ( )
Returns
bool

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

References $_SERVER.

74  {
75  $_SERVER["PHP_AUTH_USER"] = "xcache";
76  $_SERVER["PHP_AUTH_PW"] = "xcache";
77 
78  xcache_clear_cache(XC_TYPE_VAR, 0);
79 
80  return true;
81  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

◆ get()

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

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

References ilGlobalCacheService\returnKey().

56  {
57  return xcache_get($this->returnKey($key));
58  }
+ Here is the call graph for this function:

◆ getActive()

ilXcache::getActive ( )
protected
Returns
bool

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

References ilGlobalCacheService\$active.

107  {
108  $function_exists = function_exists('xcache_set');
109  $var_size = ini_get('xcache.var_size') != '0M';
110  $var_count = ini_get('xcache.var_count') > 0;
111  $api = (php_sapi_name() !== 'cli');
112 
113  $active = $function_exists AND $var_size AND $var_count AND $api;
114 
115  return $active;
116  }

◆ getInfo()

ilXcache::getInfo ( )
Returns
array

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

References ilGlobalCacheService\isActive().

130  {
131  if ($this->isActive()) {
132  return xcache_info(XC_TYPE_VAR, 0);
133  }
134  }
+ Here is the call graph for this function:

◆ getInstallable()

ilXcache::getInstallable ( )
protected
Returns
bool

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

122  {
123  return function_exists('xcache_set');
124  }

◆ getMemoryLimit()

ilXcache::getMemoryLimit ( )
protected
Returns
int|string

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

140  {
141  return ini_get('xcache.var_size');
142  }

◆ getMinMemory()

ilXcache::getMinMemory ( )
protected
Returns
int

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

148  {
149  return self::MIN_MEMORY;
150  }

◆ readValid()

ilXcache::readValid ( )
protected
Returns
void

set self::$valid_keys from GlobalCache

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

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

Referenced by __construct().

171  {
172  if ($this->isActive() && $this->isInstallable()) {
173  $this->valid_keys = $this->unserialize($this->get('valid_keys'));
174  $this->valid_key_hash = md5(serialize($this->valid_keys));
175  }
176  }
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 157 of file class.ilXcache.php.

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

Referenced by __destruct().

157  {
158  if ($this->isActive()) {
159  if ($this->valid_key_hash != md5(serialize($this->valid_keys))) {
160  $this->set('valid_keys', $this->serialize($this->valid_keys));
161  }
162  }
163  }
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 89 of file class.ilXcache.php.

Referenced by readValid(), and saveValid().

89  {
90  return serialize($value);
91  }
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 46 of file class.ilXcache.php.

References ilGlobalCacheService\returnKey().

46  {
47  return xcache_set($this->returnKey($key), $serialized_value, $ttl);
48  }
+ Here is the call graph for this function:

◆ unserialize()

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

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

Referenced by readValid().

99  {
100  return unserialize($serialized_value);
101  }
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: