ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilGlobalCacheService Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct (string $service_id, string $component)
 ilGlobalCacheService constructor. More...
 
 unserialize ($serialized_value)
 
 get (string $key)
 
 set (string $key, $serialized_value, int $ttl=null)
 
 serialize ($value)
 
 getServiceId ()
 
 setServiceId (string $service_id)
 
 getComponent ()
 
 setComponent (string $component)
 
 isActive ()
 
 isInstallable ()
 
 returnKey (string $key)
 
 getInfo ()
 
 getInstallationFailureReason ()
 
 exists (string $key)
 
 delete (string $key)
 
 flush (bool $complete=false)
 
 setServiceType (int $service_type)
 
 getServiceType ()
 
 setValid (string $key)
 Declare a key as valid. More...
 
 isValid (string $key)
 Checks whether the cache key is valid or not. More...
 

Protected Member Functions

 getActive ()
 
 getInstallable ()
 
 getMemoryLimit ()
 
 getMinMemory ()
 
 checkMemory ()
 

Protected Attributes

int $current_time = 0
 
array $valid_keys = array()
 
string $service_id = ''
 
string $component = ''
 
int $service_type = ilGlobalCache::TYPE_STATIC
 
string $valid_key_hash = ''
 

Static Protected Attributes

static array $active = array()
 
static array $installable = array()
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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 25 of file class.ilGlobalCacheService.php.

Constructor & Destructor Documentation

◆ __construct()

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

ilGlobalCacheService constructor.

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

References ILIAS\LTI\ToolProvider\$key, checkMemory(), getActive(), getInstallable(), serialize(), setComponent(), setServiceId(), and unserialize().

40  {
41  $this->setComponent($component);
42  $this->setServiceId($service_id);
43  self::$active[static::class] = $this->getActive();
44  self::$installable[static::class] = ($this->getInstallable() && $this->checkMemory());
45  }
setServiceId(string $service_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ checkMemory()

ilGlobalCacheService::checkMemory ( )
protected

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

References ILIAS\LTI\ToolProvider\$key, exists(), flush(), getMemoryLimit(), and getMinMemory().

Referenced by __construct(), and getInstallationFailureReason().

135  : bool
136  {
137  $matches = [];
138  $memory_limit = $this->getMemoryLimit();
139  if (preg_match('#(\d*)([M|K])#uim', $memory_limit, $matches)) {
140  if ($matches[2] === 'M') {
141  $memory_limit = $matches[1] * 1024 * 1024;
142  } elseif ($matches[2] === 'K') {
143  $memory_limit = $matches[1] * 1024;
144  }
145  } else {
146  $memory_limit *= 1024 * 1024; // nnnM -> nnn MB
147  }
148 
149  return ($memory_limit >= $this->getMinMemory() * 1024 * 1024);
150  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilGlobalCacheService::delete ( string  $key)
abstract

◆ exists()

ilGlobalCacheService::exists ( string  $key)
abstract

Implements ilGlobalCacheServiceInterface.

Referenced by checkMemory().

+ Here is the caller graph for this function:

◆ flush()

ilGlobalCacheService::flush ( bool  $complete = false)
abstract

Implements ilGlobalCacheServiceInterface.

Referenced by checkMemory().

+ Here is the caller graph for this function:

◆ get()

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

Implements ilGlobalCacheServiceInterface.

◆ getActive()

ilGlobalCacheService::getActive ( )
abstractprotected

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getComponent()

ilGlobalCacheService::getComponent ( )

Implements ilGlobalCacheServiceInterface.

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

References $component.

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

83  : string
84  {
85  return $this->component;
86  }
+ Here is the caller graph for this function:

◆ getInfo()

ilGlobalCacheService::getInfo ( )

Implements ilGlobalCacheServiceInterface.

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

108  : array
109  {
110  return array();
111  }

◆ getInstallable()

ilGlobalCacheService::getInstallable ( )
abstractprotected

Referenced by __construct(), and getInstallationFailureReason().

+ Here is the caller graph for this function:

◆ getInstallationFailureReason()

ilGlobalCacheService::getInstallationFailureReason ( )

Implements ilGlobalCacheServiceInterface.

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

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

113  : string
114  {
115  if (!$this->getInstallable()) {
116  return 'Not installed';
117  }
118  if (!$this->checkMemory()) {
119  return 'Not enough Cache-Memory, set to at least ' . $this->getMinMemory() . 'M';
120  }
121 
122  return 'Unknown reason';
123  }
+ Here is the call graph for this function:

◆ getMemoryLimit()

ilGlobalCacheService::getMemoryLimit ( )
protected

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

Referenced by checkMemory().

125  : string
126  {
127  return '9999M';
128  }
+ Here is the caller graph for this function:

◆ getMinMemory()

ilGlobalCacheService::getMinMemory ( )
protected

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

Referenced by checkMemory(), and getInstallationFailureReason().

130  : int
131  {
132  return 0;
133  }
+ Here is the caller graph for this function:

◆ getServiceId()

ilGlobalCacheService::getServiceId ( )

Implements ilGlobalCacheServiceInterface.

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

References $service_id.

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

73  : string
74  {
75  return $this->service_id;
76  }
+ Here is the caller graph for this function:

◆ getServiceType()

ilGlobalCacheService::getServiceType ( )

Implements ilGlobalCacheServiceInterface.

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

References $service_type.

163  : int
164  {
165  return $this->service_type;
166  }

◆ isActive()

ilGlobalCacheService::isActive ( )

Implements ilGlobalCacheServiceInterface.

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

93  : bool
94  {
95  return self::$active[static::class];
96  }

◆ isInstallable()

ilGlobalCacheService::isInstallable ( )

Implements ilGlobalCacheServiceInterface.

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

Referenced by ilMemcache\getInfo().

98  : bool
99  {
100  return self::$installable[static::class];
101  }
+ Here is the caller graph for this function:

◆ isValid()

ilGlobalCacheService::isValid ( string  $key)

Checks whether the cache key is valid or not.

Implements ilGlobalCacheServiceInterface.

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

173  : bool
174  {
175  return isset($this->valid_keys[$key]);
176  }
string $key
Consumer key/client ID value.
Definition: System.php:193

◆ returnKey()

ilGlobalCacheService::returnKey ( string  $key)

Implements ilGlobalCacheServiceInterface.

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

References ILIAS\LTI\ToolProvider\$key, getComponent(), and getServiceId().

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

103  : string
104  {
105  return $this->getServiceId() . '_' . $this->getComponent() . '_' . $key;
106  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

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

Referenced by __construct().

+ Here is the caller graph for this function:

◆ set()

ilGlobalCacheService::set ( string  $key,
  $serialized_value,
int  $ttl = null 
)
abstract
Parameters
mixed$serialized_value

Implements ilGlobalCacheServiceInterface.

◆ setComponent()

ilGlobalCacheService::setComponent ( string  $component)

Implements ilGlobalCacheServiceInterface.

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

References $component.

Referenced by __construct().

88  : void
89  {
90  $this->component = $component;
91  }
+ Here is the caller graph for this function:

◆ setServiceId()

ilGlobalCacheService::setServiceId ( string  $service_id)

Implements ilGlobalCacheServiceInterface.

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

References $service_id.

Referenced by __construct().

78  : void
79  {
80  $this->service_id = $service_id;
81  }
+ Here is the caller graph for this function:

◆ setServiceType()

ilGlobalCacheService::setServiceType ( int  $service_type)

Implements ilGlobalCacheServiceInterface.

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

References $service_type.

158  : void
159  {
160  $this->service_type = $service_type;
161  }

◆ setValid()

ilGlobalCacheService::setValid ( string  $key)

Declare a key as valid.

If the key is already known no action is taken.

Implements ilGlobalCacheServiceInterface.

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

References ILIAS\LTI\ToolProvider\$key.

168  : void
169  {
170  $this->valid_keys[$key] = true;
171  }
string $key
Consumer key/client ID value.
Definition: System.php:193

◆ unserialize()

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

Implements ilGlobalCacheServiceInterface.

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $active

array ilGlobalCacheService::$active = array()
staticprotected

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

◆ $component

string ilGlobalCacheService::$component = ''
protected

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

Referenced by getComponent(), and setComponent().

◆ $current_time

int ilGlobalCacheService::$current_time = 0
protected

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

◆ $installable

array ilGlobalCacheService::$installable = array()
staticprotected

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

◆ $service_id

string ilGlobalCacheService::$service_id = ''
protected

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

Referenced by getServiceId(), and setServiceId().

◆ $service_type

int ilGlobalCacheService::$service_type = ilGlobalCache::TYPE_STATIC
protected

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

Referenced by getServiceType(), and setServiceType().

◆ $valid_key_hash

string ilGlobalCacheService::$valid_key_hash = ''
protected

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

◆ $valid_keys

array ilGlobalCacheService::$valid_keys = array()
protected

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


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