ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilGlobalCacheService Class Reference

Class ilGlobalCacheService. More...

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

Public Member Functions

 __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...
 

Protected Member Functions

 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.

Base class for all concrete cache implementations.

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

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

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented in ilShm, and ilXcache.

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

51 {
54 self::$active[get_called_class()] = $this->getActive();
55 self::$installable[get_called_class()] = ($this->getInstallable() AND $this->checkMemory());
56 }

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

+ Here is the call graph for this function:

Member Function Documentation

◆ checkMemory()

ilGlobalCacheService::checkMemory ( )
protected
Returns
bool

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

205 {
206 $matches = array();
207 $memory_limit = $this->getMemoryLimit();
208 if (preg_match('/([0-9]*)([M|K])/uism', $memory_limit, $matches)) {
209 switch ($matches[2]) {
210 case 'M':
211 $memory_limit = $matches[1] * 1024 * 1024; // nnnM -> nnn MB
212 break;
213 case 'K':
214 $memory_limit = $matches[1] * 1024; // nnnK -> nnn KB
215 break;
216 }
217 } else {
218 $memory_limit = $memory_limit * 1024 * 1024; // nnnM -> nnn MB
219 }
220
221 return ($memory_limit >= $this->getMinMemory() * 1024 * 1024);
222 }

References getMemoryLimit(), and getMinMemory().

Referenced by __construct(), and getInstallationFailureReason().

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

◆ delete()

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

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

◆ exists()

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

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

◆ flush()

ilGlobalCacheService::flush ( )
abstract
Returns
mixed

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

◆ get()

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

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

◆ getActive()

ilGlobalCacheService::getActive ( )
abstractprotected
Returns
bool

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

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getComponent()

ilGlobalCacheService::getComponent ( )
Returns
string

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

124 {
125 return $this->component;
126 }

References $component.

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

+ Here is the caller graph for this function:

◆ getInfo()

ilGlobalCacheService::getInfo ( )
Returns
array

Reimplemented in ilApc, ilMemcache, and ilXcache.

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

166 {
167 return array();
168 }

◆ getInstallable()

ilGlobalCacheService::getInstallable ( )
abstractprotected
Returns
bool

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

Referenced by __construct(), and getInstallationFailureReason().

+ Here is the caller graph for this function:

◆ getInstallationFailureReason()

ilGlobalCacheService::getInstallationFailureReason ( )
Returns
string

Reimplemented in ilMemcache.

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

174 {
175 if (!$this->getInstallable()) {
176 return 'Not installed';
177 }
178 if (!$this->checkMemory()) {
179 return 'Not enough Cache-Memory, set to at least ' . $this->getMinMemory() . 'M';
180 }
181
182 return 'Unknown reason';
183 }

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

+ Here is the call graph for this function:

◆ getMemoryLimit()

ilGlobalCacheService::getMemoryLimit ( )
protected
Returns
int

Reimplemented in ilApc, and ilXcache.

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

189 {
190 return 9999;
191 }

Referenced by checkMemory().

+ Here is the caller graph for this function:

◆ getMinMemory()

ilGlobalCacheService::getMinMemory ( )
protected
Returns
int

Reimplemented in ilApc, and ilXcache.

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

197 {
198 return 0;
199 }

Referenced by checkMemory(), and getInstallationFailureReason().

+ Here is the caller graph for this function:

◆ getServiceId()

ilGlobalCacheService::getServiceId ( )
Returns
string

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

108 {
109 return $this->service_id;
110 }

References $service_id.

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

+ Here is the caller graph for this function:

◆ getServiceType()

ilGlobalCacheService::getServiceType ( )
Returns
int

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

References $service_type.

◆ isActive()

ilGlobalCacheService::isActive ( )
Returns
bool

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

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

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

+ Here is the caller graph for this function:

◆ isInstallable()

ilGlobalCacheService::isInstallable ( )
Returns
bool

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

148 {
149 return self::$installable[get_called_class()];
150 }

Referenced by ilXcache\readValid().

+ Here is the caller graph for this function:

◆ isValid()

ilGlobalCacheService::isValid (   $key)

Checks whether the cache key is valid or not.

This method exists only for legacy reasons and has only a real function in combination with XCache.

Parameters
string$keyThe key which should be checked.
Returns
bool True if the key is valid otherwise false.

Reimplemented in ilApc, and ilMemcache.

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

307 {
308 return isset($this->valid_keys[$key]);
309 }

◆ returnKey()

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

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

158 {
159 return $str = $this->getServiceId() . '_' . $this->getComponent() . '_' . $key;
160 }

References getComponent(), and getServiceId().

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

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

◆ serialize()

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

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

◆ set()

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

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

◆ setComponent()

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

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

132 {
133 $this->component = $component;
134 }

References $component.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setInvalid()

ilGlobalCacheService::setInvalid (   $key = null)

Set the key as invalid.

This method will invalidate all keys if no argument is given or null.

This method exists only for legacy reasons and has only a real function in combination with XCache.

Parameters
string$keyThe key which should be invalidated or null to invalidate all.
Returns
void

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

288 {
289 if ($key !== NULL) {
290 unset($this->valid_keys[$key]);
291 } else {
292 unset($this->valid_keys);
293 }
294 }

◆ setServiceId()

ilGlobalCacheService::setServiceId (   $service_id)
Parameters
string$service_id

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

116 {
117 $this->service_id = $service_id;
118 }

References $service_id.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setServiceType()

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

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

250 {
251 $this->service_type = $service_type;
252 }

References $service_type.

◆ setValid()

ilGlobalCacheService::setValid (   $key)

Declare a key as valid.

If the key is already known no action is taken.

This method exists only for legacy reasons and has only a real function in combination with XCache.

Parameters
string$keyThe key which should be declared as valid.
Returns
void

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

273 {
274 $this->valid_keys[$key] = true;
275 }

◆ unserialize()

ilGlobalCacheService::unserialize (   $serialized_value)
abstract
Parameters
$serialized_value
Returns
mixed

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

Field Documentation

◆ $active

ilGlobalCacheService::$active = array()
staticprotected

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

Referenced by ilXcache\getActive().

◆ $component

ilGlobalCacheService::$component = ''
protected

◆ $current_time

ilGlobalCacheService::$current_time = 0
protected

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

◆ $installable

ilGlobalCacheService::$installable = array()
staticprotected

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

◆ $service_id

ilGlobalCacheService::$service_id = ''
protected

◆ $service_type

ilGlobalCacheService::$service_type = ilGlobalCache::TYPE_STATIC
protected

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

Referenced by getServiceType(), and setServiceType().

◆ $valid_key_hash

ilGlobalCacheService::$valid_key_hash = ''
protected

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

◆ $valid_keys

ilGlobalCacheService::$valid_keys = array()
protected

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


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