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

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

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

51  {
52  $this->setComponent($component);
53  $this->setServiceId($service_id);
54  self::$active[get_called_class()] = $this->getActive();
55  self::$installable[get_called_class()] = ($this->getInstallable() AND $this->checkMemory());
56  }
+ 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.

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

Referenced by __construct(), and getInstallationFailureReason().

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  }
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 124 of file class.ilGlobalCacheService.php.

References $component.

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

124  {
125  return $this->component;
126  }
+ Here is the caller graph for this function:

◆ getInfo()

ilGlobalCacheService::getInfo ( )
Returns
array

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

References array.

166  {
167  return array();
168  }
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 174 of file class.ilGlobalCacheService.php.

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

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

◆ getMemoryLimit()

ilGlobalCacheService::getMemoryLimit ( )
protected
Returns
int

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

Referenced by checkMemory().

189  {
190  return 9999;
191  }
+ Here is the caller graph for this function:

◆ getMinMemory()

ilGlobalCacheService::getMinMemory ( )
protected
Returns
int

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

Referenced by checkMemory(), and getInstallationFailureReason().

197  {
198  return 0;
199  }
+ Here is the caller graph for this function:

◆ getServiceId()

ilGlobalCacheService::getServiceId ( )
Returns
string

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

References $service_id.

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

108  {
109  return $this->service_id;
110  }
+ 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.

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

140  {
141  return self::$active[get_called_class()];
142  }
+ Here is the caller graph for this function:

◆ isInstallable()

ilGlobalCacheService::isInstallable ( )
Returns
bool

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

Referenced by ilXcache\readValid().

148  {
149  return self::$installable[get_called_class()];
150  }
+ 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 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.

References 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().

158  {
159  return $str = $this->getServiceId() . '_' . $this->getComponent() . '_' . $key;
160  }
+ 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 132 of file class.ilGlobalCacheService.php.

References $component.

Referenced by __construct().

132  {
133  $this->component = $component;
134  }
+ 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.

References $service_id.

Referenced by __construct().

116  {
117  $this->service_id = $service_id;
118  }
+ 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.

References $service_type.

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

◆ 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

Referenced by __construct().

+ Here is the caller graph for this function:

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: