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

Reimplemented from ilGlobalCacheService.

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

23 {
24 parent::__construct($serviceId, $component);
25 $this->readValid();
26 }

References ilGlobalCacheService\$component, and readValid().

+ Here is the call graph for this function:

◆ __destruct()

ilXcache::__destruct ( )

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

178 {
179 $this->saveValid();
180 }

References saveValid().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

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

Reimplemented from ilGlobalCacheService.

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

66 {
67 return xcache_unset($this->returnKey($key));
68 }

References ilGlobalCacheService\returnKey().

+ Here is the call graph for this function:

◆ exists()

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

Reimplemented from ilGlobalCacheService.

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

34 {
35 return xcache_isset($this->returnKey($key));
36 }

References ilGlobalCacheService\returnKey().

+ Here is the call graph for this function:

◆ flush()

ilXcache::flush ( )
Returns
bool

Reimplemented from ilGlobalCacheService.

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

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']

References $_SERVER.

◆ get()

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

Reimplemented from ilGlobalCacheService.

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

56 {
57 return xcache_get($this->returnKey($key));
58 }

References ilGlobalCacheService\returnKey().

+ Here is the call graph for this function:

◆ getActive()

ilXcache::getActive ( )
protected
Returns
bool

Reimplemented from ilGlobalCacheService.

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

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 }

References ilGlobalCacheService\$active.

◆ getInfo()

ilXcache::getInfo ( )
Returns
array

Reimplemented from ilGlobalCacheService.

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

130 {
131 if ($this->isActive()) {
132 return xcache_info(XC_TYPE_VAR, 0);
133 }
134 }

References ilGlobalCacheService\isActive().

+ Here is the call graph for this function:

◆ getInstallable()

ilXcache::getInstallable ( )
protected
Returns
bool

Reimplemented from ilGlobalCacheService.

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

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

◆ getMemoryLimit()

ilXcache::getMemoryLimit ( )
protected
Returns
int|string

Reimplemented from ilGlobalCacheService.

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

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

◆ getMinMemory()

ilXcache::getMinMemory ( )
protected
Returns
int

Reimplemented from ilGlobalCacheService.

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

148 {
149 return self::MIN_MEMORY;
150 }
const MIN_MEMORY

References MIN_MEMORY.

◆ readValid()

ilXcache::readValid ( )
protected
Returns
void

@description set self::$valid_keys from GlobalCache

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

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)

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

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveValid()

ilXcache::saveValid ( )
protected
Returns
void

@description save self::$valid_keys to GlobalCache

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

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 }

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

Referenced by __destruct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

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

Reimplemented from ilGlobalCacheService.

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

89 {
90 return serialize($value);
91 }

References serialize().

Referenced by readValid(), saveValid(), and serialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set()

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

Reimplemented from ilGlobalCacheService.

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

46 {
47 return xcache_set($this->returnKey($key), $serialized_value, $ttl);
48 }

References ilGlobalCacheService\returnKey().

+ Here is the call graph for this function:

◆ unserialize()

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

Reimplemented from ilGlobalCacheService.

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

99 {
100 return unserialize($serialized_value);
101 }

References unserialize().

Referenced by readValid(), and unserialize().

+ Here is the call graph for this function:
+ 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.

Referenced by getMinMemory().


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