ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMemcache Class Reference

Class ilMemcache. More...

+ Inheritance diagram for ilMemcache:
+ Collaboration diagram for ilMemcache:

Public Member Functions

 exists ($key)
 
 set ($key, $serialized_value, $ttl=null)
 
 get ($key)
 
 delete ($key)
 
 flush ($complete=false)
 
 getInstallationFailureReason ()
 
 serialize ($value)
 
 unserialize ($serialized_value)
 
 getInfo ()
 
 isValid ($key)
 
- Public Member Functions inherited from ilGlobalCacheService
 __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 ($complete=false)
 
 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

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

Static Protected Attributes

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

Additional Inherited Members

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

Detailed Description

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 12 of file class.ilMemcache.php.

Member Function Documentation

◆ delete()

ilMemcache::delete (   $key)
Parameters
$key
Returns
bool

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

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

105  {
106  return $this->getMemcacheObject()->delete($this->returnKey($key));
107  }
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ exists()

ilMemcache::exists (   $key)
Parameters
$key
Returns
bool

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

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

69  {
70  return $this->getMemcacheObject()->get($this->returnKey($key)) != null;
71  }
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ flush()

ilMemcache::flush (   $complete = false)
Parameters
bool$complete
Returns
bool

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

References getMemcacheObject().

116  {
117  // currently a partial flushing is missing
118  return $this->getMemcacheObject()->flush();
119  }
+ Here is the call graph for this function:

◆ get()

ilMemcache::get (   $key)
Parameters
$key
Returns
mixed

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

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

94  {
95  return $this->getMemcacheObject()->get($this->returnKey($key));
96  }
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ getActive()

ilMemcache::getActive ( )
protected
Returns
bool

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

References $server, Sabre\VObject\$stats, getInstallable(), and getMemcacheObject().

126  {
127  if ($this->getInstallable()) {
128  $stats = $this->getMemcacheObject()->getStats();
129 
130  if (!is_array($stats)) {
131  return false;
132  }
133 
134  foreach ($stats as $server) {
135  if ($server['pid'] > 0) {
136  return true;
137  }
138  }
139 
140  return false;
141  }
142 
143  return false;
144  }
$server
Definition: sabredav.php:48
+ Here is the call graph for this function:

◆ getInfo()

ilMemcache::getInfo ( )
Returns
array

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

References $key, and getMemcacheObject().

199  {
200  if (self::isInstallable()) {
201  $return = array();
202  $return['__cache_info'] = $this->getMemcacheObject()->getStats();
203  foreach ($this->getMemcacheObject()->getAllKeys() as $key) {
204  $return[$key] = $this->getMemcacheObject()->get($key);
205  }
206 
207  return $return;
208  }
209  }
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ getInstallable()

ilMemcache::getInstallable ( )
protected
Returns
bool

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

Referenced by getActive().

151  {
152  return class_exists('Memcached');
153  }
+ Here is the caller graph for this function:

◆ getInstallationFailureReason()

ilMemcache::getInstallationFailureReason ( )
Returns
string

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

References Sabre\VObject\$stats, and getMemcacheObject().

160  {
161  if ($this->getMemcacheObject() instanceof Memcached) {
162  $stats = $this->getMemcacheObject()->getStats();
163 
164  if (!$stats[self::STD_SERVER . ':' . self::STD_PORT]['pid'] > 0) {
165  return 'No Memcached-Server available';
166  }
167  }
168 
169  return parent::getInstallationFailureReason();
170  }
+ Here is the call graph for this function:

◆ getMemcacheObject()

ilMemcache::getMemcacheObject ( )
protected
Returns
Memcached

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

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

58  {
59  return self::$memcache_object;
60  }
+ Here is the caller graph for this function:

◆ isValid()

ilMemcache::isValid (   $key)

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

216  {
217  return true;
218  }

◆ serialize()

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

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

179  {
180  return serialize($value);
181  }

◆ set()

ilMemcache::set (   $key,
  $serialized_value,
  $ttl = null 
)
Parameters
$key
$serialized_value
null | int$ttl
Returns
bool

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

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

82  {
83  return $this->getMemcacheObject()
84  ->set($this->returnKey($key), $serialized_value, (int) $ttl);
85  }
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ unserialize()

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

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

190  {
191  return unserialize($serialized_value);
192  }
unserialize($serialized_value)

Field Documentation

◆ $memcache_object

ilMemcache::$memcache_object
staticprotected

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


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