ILIAS  release_8 Revision v8.23
ilMemcache 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 ilMemcache:
+ Collaboration diagram for ilMemcache:

Public Member Functions

 exists (string $key)
 
 set (string $key, $serialized_value, int $ttl=null)
 
 get (string $key)
 
 delete (string $key)
 
 flush (bool $complete=false)
 
 getInstallationFailureReason ()
 
 serialize ($value)
 
 unserialize ($serialized_value)
 
 getInfo ()
 
 isValid (string $key)
 Checks whether the cache key is valid or not. More...
 
- Public Member Functions inherited from ilGlobalCacheService
 __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

 getMemcacheObject ()
 
 getActive ()
 
 getInstallable ()
 
- Protected Member Functions inherited from ilGlobalCacheService
 getActive ()
 
 getInstallable ()
 
 getMemoryLimit ()
 
 getMinMemory ()
 
 checkMemory ()
 

Static Protected Attributes

static Memcached $memcache_object = null
 
- Static Protected Attributes inherited from ilGlobalCacheService
static array $active = array()
 
static array $installable = array()
 

Additional Inherited Members

- Protected Attributes inherited from ilGlobalCacheService
int $current_time = 0
 
array $valid_keys = array()
 
string $service_id = ''
 
string $component = ''
 
int $service_type = ilGlobalCache::TYPE_STATIC
 
string $valid_key_hash = ''
 

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 ilMemcache

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

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

Member Function Documentation

◆ delete()

ilMemcache::delete ( string  $key)

Implements ilGlobalCacheServiceInterface.

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

References getMemcacheObject(), and ilGlobalCacheService\returnKey().

83  : bool
84  {
85  return $this->getMemcacheObject()->delete($this->returnKey($key));
86  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:

◆ exists()

ilMemcache::exists ( string  $key)

Implements ilGlobalCacheServiceInterface.

Definition at line 64 of file class.ilMemcache.php.

References getMemcacheObject(), and ilGlobalCacheService\returnKey().

64  : bool
65  {
66  return $this->getMemcacheObject()->get($this->returnKey($key)) !== null;
67  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:

◆ flush()

ilMemcache::flush ( bool  $complete = false)

Implements ilGlobalCacheServiceInterface.

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

References getMemcacheObject().

88  : bool
89  {
90  return $this->getMemcacheObject()->flush();
91  }
+ Here is the call graph for this function:

◆ get()

ilMemcache::get ( string  $key)
Returns
mixed

Implements ilGlobalCacheServiceInterface.

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

References getMemcacheObject(), and ilGlobalCacheService\returnKey().

79  {
80  return $this->getMemcacheObject()->get($this->returnKey($key));
81  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:

◆ getActive()

ilMemcache::getActive ( )
protected

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

References $server, getInstallable(), and getMemcacheObject().

93  : bool
94  {
95  if ($this->getInstallable()) {
96  $stats = $this->getMemcacheObject()->getStats();
97 
98  if (!is_array($stats)) {
99  return false;
100  }
101 
102  foreach ($stats as $server) {
103  if ((int) $server['pid'] > 1) {
104  return true;
105  }
106  }
107 
108  return false;
109  }
110 
111  return false;
112  }
$server
+ Here is the call graph for this function:

◆ getInfo()

ilMemcache::getInfo ( )

Implements ilGlobalCacheServiceInterface.

Definition at line 151 of file class.ilMemcache.php.

References ILIAS\LTI\ToolProvider\$key, getMemcacheObject(), and ilGlobalCacheService\isInstallable().

151  : array
152  {
153  $return = [];
154  if ($this->isInstallable()) {
155  $return['__cache_info'] = $this->getMemcacheObject()->getStats();
156  foreach ($this->getMemcacheObject()->getAllKeys() as $key) {
157  $return[$key] = $this->getMemcacheObject()->get($key);
158  }
159  }
160  return $return;
161  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:

◆ getInstallable()

ilMemcache::getInstallable ( )
protected

Definition at line 114 of file class.ilMemcache.php.

Referenced by getActive().

114  : bool
115  {
116  return class_exists('Memcached');
117  }
+ Here is the caller graph for this function:

◆ getInstallationFailureReason()

ilMemcache::getInstallationFailureReason ( )

Implements ilGlobalCacheServiceInterface.

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

References $server, and getMemcacheObject().

119  : string
120  {
121  $stats = $this->getMemcacheObject()->getStats();
122  $server_available = false;
123  foreach ($stats as $server) {
124  if ($server['pid'] > 0) {
125  $server_available = true;
126  }
127  }
128  if (!$server_available) {
129  return 'No Memcached-Server available';
130  }
131  return parent::getInstallationFailureReason();
132  }
$server
+ Here is the call graph for this function:

◆ getMemcacheObject()

ilMemcache::getMemcacheObject ( )
protected

Definition at line 59 of file class.ilMemcache.php.

Referenced by delete(), exists(), flush(), get(), getActive(), getInfo(), getInstallationFailureReason(), and set().

59  : ?\Memcached
60  {
61  return self::$memcache_object;
62  }
+ Here is the caller graph for this function:

◆ isValid()

ilMemcache::isValid ( string  $key)

Checks whether the cache key is valid or not.

Implements ilGlobalCacheServiceInterface.

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

163  : bool
164  {
165  return true;
166  }

◆ serialize()

ilMemcache::serialize (   $value)
Parameters
mixed$value

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

137  : string
138  {
139  return serialize($value);
140  }

◆ set()

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

Implements ilGlobalCacheServiceInterface.

Definition at line 69 of file class.ilMemcache.php.

References getMemcacheObject(), and ilGlobalCacheService\returnKey().

69  : bool
70  {
71  return $this->getMemcacheObject()
72  ->set($this->returnKey($key), $serialized_value, (int) $ttl);
73  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:

◆ unserialize()

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

Implements ilGlobalCacheServiceInterface.

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

147  {
148  return unserialize($serialized_value);
149  }
unserialize($serialized_value)

Field Documentation

◆ $memcache_object

Memcached ilMemcache::$memcache_object = null
staticprotected

Definition at line 26 of file class.ilMemcache.php.


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