ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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

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

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

53  {
54  $this->setComponent($component);
55  $this->setServiceId($service_id);
56  self::$active[get_called_class()] = $this->getActive();
57  self::$installable[get_called_class()] = ($this->getInstallable() and $this->checkMemory());
58  }
+ Here is the call graph for this function:

Member Function Documentation

◆ checkMemory()

ilGlobalCacheService::checkMemory ( )
protected
Returns
bool

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

References $key, array, exists(), flush(), getMemoryLimit(), and getMinMemory().

Referenced by __construct(), and getInstallationFailureReason().

219  {
220  $matches = array();
221  $memory_limit = $this->getMemoryLimit();
222  if (preg_match('/([0-9]*)([M|K])/uism', $memory_limit, $matches)) {
223  switch ($matches[2]) {
224  case 'M':
225  $memory_limit = $matches[1] * 1024 * 1024; // nnnM -> nnn MB
226  break;
227  case 'K':
228  $memory_limit = $matches[1] * 1024; // nnnK -> nnn KB
229  break;
230  }
231  } else {
232  $memory_limit = $memory_limit * 1024 * 1024; // nnnM -> nnn MB
233  }
234 
235  return ($memory_limit >= $this->getMinMemory() * 1024 * 1024);
236  }
Create styles array
The data for the language used.
+ 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

◆ exists()

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

Referenced by checkMemory().

+ Here is the caller graph for this function:

◆ flush()

ilGlobalCacheService::flush ( )
abstract
Returns
mixed

Referenced by checkMemory().

+ Here is the caller graph for this function:

◆ get()

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

◆ getActive()

ilGlobalCacheService::getActive ( )
abstractprotected
Returns
bool

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getComponent()

ilGlobalCacheService::getComponent ( )
Returns
string

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

References $component.

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

129  {
130  return $this->component;
131  }
+ Here is the caller graph for this function:

◆ getInfo()

ilGlobalCacheService::getInfo ( )
Returns
array

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

References array.

176  {
177  return array();
178  }
Create styles array
The data for the language used.

◆ getInstallable()

ilGlobalCacheService::getInstallable ( )
abstractprotected
Returns
bool

Referenced by __construct(), and getInstallationFailureReason().

+ Here is the caller graph for this function:

◆ getInstallationFailureReason()

ilGlobalCacheService::getInstallationFailureReason ( )
Returns
string

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

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

185  {
186  if (!$this->getInstallable()) {
187  return 'Not installed';
188  }
189  if (!$this->checkMemory()) {
190  return 'Not enough Cache-Memory, set to at least ' . $this->getMinMemory() . 'M';
191  }
192 
193  return 'Unknown reason';
194  }
+ Here is the call graph for this function:

◆ getMemoryLimit()

ilGlobalCacheService::getMemoryLimit ( )
protected
Returns
int

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

Referenced by checkMemory().

201  {
202  return 9999;
203  }
+ Here is the caller graph for this function:

◆ getMinMemory()

ilGlobalCacheService::getMinMemory ( )
protected
Returns
int

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

Referenced by checkMemory(), and getInstallationFailureReason().

210  {
211  return 0;
212  }
+ Here is the caller graph for this function:

◆ getServiceId()

ilGlobalCacheService::getServiceId ( )
Returns
string

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

References $service_id.

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

111  {
112  return $this->service_id;
113  }
+ Here is the caller graph for this function:

◆ getServiceType()

ilGlobalCacheService::getServiceType ( )
Returns
int

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

References $service_type.

◆ isActive()

ilGlobalCacheService::isActive ( )
Returns
bool

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

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

147  {
148  return self::$active[get_called_class()];
149  }
+ Here is the caller graph for this function:

◆ isInstallable()

ilGlobalCacheService::isInstallable ( )
Returns
bool

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

Referenced by ilXcache\readValid().

156  {
157  return self::$installable[get_called_class()];
158  }
+ 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.

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

References $key.

326  {
327  return isset($this->valid_keys[$key]);
328  }
$key
Definition: croninfo.php:18

◆ returnKey()

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

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

References $key, getComponent(), and getServiceId().

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

167  {
168  return $str = $this->getServiceId() . '_' . $this->getComponent() . '_' . $key;
169  }
$key
Definition: croninfo.php:18
+ 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

Referenced by __construct().

+ Here is the caller graph for this function:

◆ set()

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

◆ setComponent()

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

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

References $component.

Referenced by __construct().

138  {
139  $this->component = $component;
140  }
+ 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 305 of file class.ilGlobalCacheService.php.

References $key.

306  {
307  if ($key !== null) {
308  unset($this->valid_keys[$key]);
309  } else {
310  unset($this->valid_keys);
311  }
312  }
$key
Definition: croninfo.php:18

◆ setServiceId()

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

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

References $service_id.

Referenced by __construct().

120  {
121  $this->service_id = $service_id;
122  }
+ Here is the caller graph for this function:

◆ setServiceType()

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

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

References $service_type.

265  {
266  $this->service_type = $service_type;
267  }

◆ 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 289 of file class.ilGlobalCacheService.php.

References $key.

290  {
291  $this->valid_keys[$key] = true;
292  }
$key
Definition: croninfo.php:18

◆ unserialize()

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

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $active

ilGlobalCacheService::$active = array()
staticprotected

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

Referenced by ilXcache\getActive().

◆ $component

ilGlobalCacheService::$component = ''
protected

◆ $current_time

ilGlobalCacheService::$current_time = 0
protected

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

◆ $installable

ilGlobalCacheService::$installable = array()
staticprotected

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

◆ $service_id

ilGlobalCacheService::$service_id = ''
protected

◆ $service_type

ilGlobalCacheService::$service_type = ilGlobalCache::TYPE_STATIC
protected

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

Referenced by getServiceType(), and setServiceType().

◆ $valid_key_hash

ilGlobalCacheService::$valid_key_hash = ''
protected

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

◆ $valid_keys

ilGlobalCacheService::$valid_keys = array()
protected

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


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