ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMemcache Class Reference

Class ilMemcache. More...

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

Public Member Functions

 __construct ($service_id, $component)
 
 exists ($key)
 
 set ($key, $serialized_value, $ttl=NULL)
 
 get ($key)
 
 delete ($key)
 
 flush ()
 
 getInstallationFailureReason ()
 
 serialize ($value)
 
 unserialize ($serialized_value)
 
 getInfo ()
 
- Public Member Functions inherited from ilGlobalCacheService
 __construct ($service_id, $component)
 
 __destruct ()
 
 unserialize ($serialized_value)
 
 get ($key)
 
 set ($key, $serialized_value, $ttl=NULL)
 
 serialize ($value)
 
 getServiceId ()
 
 setServiceId ($service_id)
 
 setValid ($key)
 
 getComponent ()
 
 setComponent ($component)
 
 setInvalid ($key=NULL)
 
 isValid ($key)
 
 isActive ()
 
 isInstallable ()
 
 returnKey ($key)
 
 getInfo ()
 
 getInstallationFailureReason ()
 
 exists ($key)
 
 delete ($key)
 
 flush ()
 
 setServiceType ($service_type)
 
 getServiceType ()
 

Data Fields

const STD_SERVER = '127.0.0.1'
 
const STD_PORT = 11211
 

Protected Member Functions

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

Static Protected Attributes

static $servers
 
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 11 of file class.ilMemcache.php.

Constructor & Destructor Documentation

◆ __construct()

ilMemcache::__construct (   $service_id,
  $component 
)
Parameters
$service_id
$component

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

References ilGlobalCacheService\$component, ilGlobalCacheService\$service_id, and getInstallable().

31  {
32  if (! (self::$memcache_object instanceof Memcached) AND $this->getInstallable()) {
33  $memcached = new Memcached();
34  foreach (self::$servers as $host => $port) {
35  $memcached->addServer($host, $port);
36  }
37  self::$memcache_object = $memcached;
38  }
39  parent::__construct($service_id, $component);
40  }
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

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

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

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

88  {
89  return $this->getMemcacheObject()->delete($this->returnKey($key));
90  }
+ Here is the call graph for this function:

◆ exists()

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

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

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

56  {
57  return $this->getMemcacheObject()->get($this->returnKey($key)) != NULL;
58  }
+ Here is the call graph for this function:

◆ flush()

ilMemcache::flush ( )
Returns
bool

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

References getMemcacheObject().

96  {
97  return $this->getMemcacheObject()->flush();
98  }
+ Here is the call graph for this function:

◆ get()

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

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

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

78  {
79  return $this->getMemcacheObject()->get($this->returnKey($key));
80  }
+ Here is the call graph for this function:

◆ getActive()

ilMemcache::getActive ( )
protected
Returns
bool

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

References getInstallable(), and getMemcacheObject().

104  {
105  if ($this->getInstallable()) {
106  $stats = $this->getMemcacheObject()->getStats();
107 
108  return $stats[self::STD_SERVER . ':' . self::STD_PORT]['pid'] > 0;
109  }
110  }
+ Here is the call graph for this function:

◆ getInfo()

ilMemcache::getInfo ( )
Returns
array

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

References getMemcacheObject().

160  {
161  if (self::isInstallable()) {
162  $return = array();
163  $return['__cache_info'] = $this->getMemcacheObject()->getStats();
164  foreach ($this->getMemcacheObject()->getAllKeys() as $key) {
165  $return[$key] = $this->getMemcacheObject()->get($key);
166  }
167 
168  return $return;
169  }
170  }
+ Here is the call graph for this function:

◆ getInstallable()

ilMemcache::getInstallable ( )
protected
Returns
bool

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

Referenced by __construct(), and getActive().

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

◆ getInstallationFailureReason()

ilMemcache::getInstallationFailureReason ( )
Returns
string

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

References getMemcacheObject().

124  {
125  if ($this->getMemcacheObject() instanceof Memcached) {
126  $stats = $this->getMemcacheObject()->getStats();
127 
128  if (! $stats[self::STD_SERVER . ':' . self::STD_PORT]['pid'] > 0) {
129  return 'No Memcached-Server available';
130  }
131  }
132 
133  return parent::getInstallationFailureReason();
134  }
+ Here is the call graph for this function:

◆ getMemcacheObject()

ilMemcache::getMemcacheObject ( )
protected
Returns
Memcached

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

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

46  {
47  return self::$memcache_object;
48  }
+ Here is the caller graph for this function:

◆ serialize()

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

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

142  {
143  return serialize($value);
144  }

◆ set()

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

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

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

68  {
69  return $this->getMemcacheObject()->set($this->returnKey($key), $serialized_value, $ttl);
70  }
+ Here is the call graph for this function:

◆ unserialize()

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

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

152  {
153  return unserialize($serialized_value);
154  }
unserialize($serialized_value)

Field Documentation

◆ $memcache_object

ilMemcache::$memcache_object
staticprotected

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

◆ $servers

ilMemcache::$servers
staticprotected
Initial value:
= array(
self::STD_SERVER => self::STD_PORT,
)

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

◆ STD_PORT

const ilMemcache::STD_PORT = 11211

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

◆ STD_SERVER

const ilMemcache::STD_SERVER = '127.0.0.1'

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


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