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

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

References getMemcacheObject().

114  {
115  return $this->getMemcacheObject()->flush();
116  }
+ 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 122 of file class.ilMemcache.php.

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

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

◆ getInfo()

ilMemcache::getInfo ( )
Returns
array

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

References $key, array, and getMemcacheObject().

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

◆ getInstallable()

ilMemcache::getInstallable ( )
protected
Returns
bool

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

Referenced by getActive().

148  {
149  return class_exists('Memcached');
150  }
+ Here is the caller graph for this function:

◆ getInstallationFailureReason()

ilMemcache::getInstallationFailureReason ( )
Returns
string

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

References $stats, and getMemcacheObject().

157  {
158  if ($this->getMemcacheObject() instanceof Memcached) {
159  $stats = $this->getMemcacheObject()->getStats();
160 
161  if (!$stats[self::STD_SERVER . ':' . self::STD_PORT]['pid'] > 0) {
162  return 'No Memcached-Server available';
163  }
164  }
165 
166  return parent::getInstallationFailureReason();
167  }
$stats
+ 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 212 of file class.ilMemcache.php.

213  {
214  return true;
215  }

◆ serialize()

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

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

176  {
177  return serialize($value);
178  }

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

187  {
188  return unserialize($serialized_value);
189  }
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: