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

Class ilApc. More...

+ Inheritance diagram for ilApc:
+ Collaboration diagram for ilApc:

Public Member Functions

 exists ($key)
 
 set ($key, $serialized_value, $ttl=0)
 
 get ($key)
 
 delete ($key)
 
 flush ($complete=false)
 
 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...
 

Data Fields

const MIN_MEMORY = 16
 
const CACHE_ID = 'user'
 

Protected Member Functions

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

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 = ''
 
- Static Protected Attributes inherited from ilGlobalCacheService
static $active = array()
 
static $installable = array()
 

Detailed Description

Class ilApc.

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

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

Member Function Documentation

◆ delete()

ilApc::delete (   $key)
Parameters
$key
Returns
bool|string[]

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

References $key, and ilGlobalCacheService\returnKey().

65  {
66  return apcu_delete($this->returnKey($key));
67  }
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ exists()

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

Definition at line 25 of file class.ilApc.php.

References $key, and ilGlobalCacheService\returnKey().

26  {
27  if (function_exists('apcu_exists')) {
28  return apcu_exists($this->returnKey($key));
29  } else {
30  return apcu_fetch($this->returnKey($key));
31  }
32  }
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ flush()

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

Definition at line 75 of file class.ilApc.php.

References ilGlobalCacheService\returnKey().

76  {
77  if ($complete) {
78  return apcu_clear_cache();
79  }
80 
81  $key_prefix = $this->returnKey('');
82  $apcu_iterator = new APCUIterator();
83  $apcu_iterator->rewind();
84  while ($current_key = $apcu_iterator->key()) {
85  // "begins with"
86  if (substr($current_key, 0, strlen($key_prefix)) === $key_prefix) {
87  $this->delete($current_key);
88  }
89  $apcu_iterator->next();
90  }
91  return true;
92  }
+ Here is the call graph for this function:

◆ get()

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

Definition at line 53 of file class.ilApc.php.

References $key, and ilGlobalCacheService\returnKey().

54  {
55  return apcu_fetch($this->returnKey($key));
56  }
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ getActive()

ilApc::getActive ( )
protected

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

152  {
153  return function_exists('apcu_store');
154  }

◆ getInfo()

ilApc::getInfo ( )
Returns
array

Definition at line 120 of file class.ilApc.php.

References $key, ilGlobalCacheService\getComponent(), and ilGlobalCacheService\getServiceId().

121  {
122  $return = array();
123 
124  $cache_info = apc_cache_info();
125 
126  unset($cache_info['cache_list']);
127  unset($cache_info['slot_distribution']);
128 
129  $return['__cache_info'] = array(
130  'apc.enabled' => ini_get('apc.enabled'),
131  'apc.shm_size' => ini_get('apc.shm_size'),
132  'apc.shm_segments' => ini_get('apc.shm_segments'),
133  'apc.gc_ttl' => ini_get('apc.gc_ttl'),
134  'apc.user_ttl' => ini_get('apc.ttl'),
135  'info' => $cache_info,
136  );
137 
138  $cache_info = apc_cache_info();
139  foreach ($cache_info['cache_list'] as $dat) {
140  $key = $dat['key'];
141 
142  if (preg_match('/' . $this->getServiceId() . '_' . $this->getComponent() . '/', $key)) {
143  $return[$key] = apc_fetch($key);
144  }
145  }
146 
147  return $return;
148  }
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ getInstallable()

ilApc::getInstallable ( )
protected
Returns
bool

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

161  {
162  return function_exists('apcu_store');
163  }

◆ getMemoryLimit()

ilApc::getMemoryLimit ( )
protected
Returns
string

Definition at line 169 of file class.ilApc.php.

References ilRuntime\getInstance(), and getMinMemory().

170  {
171  if (ilRuntime::getInstance()->isHHVM()) {
172  return $this->getMinMemory() . 'M';
173  }
174 
175  return ini_get('apc.shm_size');
176  }
static getInstance()
getMinMemory()
+ Here is the call graph for this function:

◆ getMinMemory()

ilApc::getMinMemory ( )
protected

Definition at line 182 of file class.ilApc.php.

Referenced by getMemoryLimit().

183  {
184  return self::MIN_MEMORY;
185  }
+ Here is the caller graph for this function:

◆ isValid()

ilApc::isValid (   $key)

Definition at line 191 of file class.ilApc.php.

192  {
193  return true;
194  }

◆ serialize()

ilApc::serialize (   $value)
Parameters
$value
Returns
mixed|string

Definition at line 100 of file class.ilApc.php.

101  {
102  return ($value);
103  }

◆ set()

ilApc::set (   $key,
  $serialized_value,
  $ttl = 0 
)
Parameters
$key
$serialized_value
int$ttl
Returns
array|bool

Definition at line 42 of file class.ilApc.php.

References $key, and ilGlobalCacheService\returnKey().

43  {
44  return apcu_store($this->returnKey($key), $serialized_value, $ttl);
45  }
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ unserialize()

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

Definition at line 111 of file class.ilApc.php.

112  {
113  return ($serialized_value);
114  }

Field Documentation

◆ CACHE_ID

const ilApc::CACHE_ID = 'user'

Definition at line 17 of file class.ilApc.php.

◆ MIN_MEMORY

const ilApc::MIN_MEMORY = 16

Definition at line 16 of file class.ilApc.php.


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