Framework  3.9
APCCache Class Reference

Provides a simple cacheing mechanism using the Alternative PHP Cache extension. More...

Public Member Functions

 APCCache ()
 
 get ($key)
 
 put ($key, $obj, $ttl=0)
 
 invalidate ($key)
 
 invalidateMatching ($pattern)
 
 clear ()
 
 dump ()
 

Detailed Description

Provides a simple cacheing mechanism using the Alternative PHP Cache extension.

Author
Andy Green

Definition at line 223 of file cache.inc.

Member Function Documentation

◆ APCCache()

APCCache::APCCache ( )

Definition at line 225 of file cache.inc.

226  {
227  trace("Creating APC Cache", 4);
228  }
trace($msg, $lvl=3, $callStack=null)
Send output to the trace log.
Definition: functions.inc:1010

◆ clear()

APCCache::clear ( )

Definition at line 264 of file cache.inc.

265  {
266  apc_clear_cache('user');
267  }

◆ dump()

APCCache::dump ( )

Definition at line 269 of file cache.inc.

270  {
271  echo "<table class='list'><thead><tr><th>Key</th><th>Value</th></tr></thead><tbody>\n";
272 
273  $prefix = ConnectionManager::$dsn."_".Cache::$app_name."_";
274 
275  foreach (new APCIterator('user', '/.*/') as $kvp)
276  {
277  if (!startsWith($kvp['key'], $prefix)) continue;
278  $key = str_replace($prefix, "", $kvp['key']);
279  $value = htmlSafe($kvp['value']);
280 
281  echo "<tr><td><b>$key</b></td><td>{$value}</td></tr>\n";
282  }
283  echo "</tbody></table>";
284  }
static $app_name
Definition: cache.inc:44
startsWith($text, $start)
Tests whether a string starts with a given sub-string.
Definition: functions.inc:1470

◆ get()

APCCache::get (   $key)

Definition at line 230 of file cache.inc.

231  {
232  $success = true;
233 
234  $s = apc_fetch($key, $success);
235  if (!$success) return null;
236 
237  return unserialize($s);
238  }

◆ invalidate()

APCCache::invalidate (   $key)

Definition at line 245 of file cache.inc.

246  {
247  return apc_delete($key);
248  }

◆ invalidateMatching()

APCCache::invalidateMatching (   $pattern)

Definition at line 250 of file cache.inc.

251  {
252  trace("invalidateMatching: $pattern", 3);
253  //TODO - Not working on zither - investigate
254  /*$iterator = new APCIterator("user", $pattern);
255 
256  while($key = $iterator->key())
257  {
258  trace($key, 3);
259  Cache::invalidate($key);
260  $iterator->next();
261  }*/
262  }

◆ put()

APCCache::put (   $key,
  $obj,
  $ttl = 0 
)

Definition at line 240 of file cache.inc.

241  {
242  return apc_store($key, serialize($obj), $ttl);
243  }

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