Framework  3.9
WCCache Class Reference

Provides a simple cacheing mechanism using the WinCache PHP extension (for use under IIS). More...

Public Member Functions

 WCCache ()
 
 get ($key)
 
 put ($key, $obj, $ttl=0)
 
 invalidate ($key)
 
 invalidateMatching ($pattern)
 
 filterKey ($key)
 Internal callback function that supports the invalidateMatching function. More...
 
 clear ()
 
 dump ()
 

Detailed Description

Provides a simple cacheing mechanism using the WinCache PHP extension (for use under IIS).

Definition at line 361 of file cache.inc.

Member Function Documentation

◆ clear()

WCCache::clear ( )

Definition at line 417 of file cache.inc.

418  {
419  wincache_ucache_clear();
420  }

◆ dump()

WCCache::dump ( )

Definition at line 422 of file cache.inc.

423  {
424  $info = wincache_ucache_info();
425  $prefix = ConnectionManager::$dsn."_".Cache::$app_name."_";
426  echo "<table class='list'><thead><tr><th>Key</th><th>Value</th></tr></thead><tbody>\n";
427  foreach ($info['ucache_entries'] as $kvp)
428  {
429  if (!startsWith($kvp['key_name'], $prefix)) continue;
430  $key = str_replace($prefix, "", $kvp['key_name']);
431 
432  echo "<tr><td><b>{$key}</b></td><td>".htmlSafe(wincache_ucache_get($kvp['key_name']))."</td></tr>\n";
433  }
434  echo "</tbody></table>";
435  }
static $app_name
Definition: cache.inc:44
startsWith($text, $start)
Tests whether a string starts with a given sub-string.
Definition: functions.inc:1470

◆ filterKey()

WCCache::filterKey (   $key)

Internal callback function that supports the invalidateMatching function.

Parameters
string$keythe key to be filtered.

Definition at line 412 of file cache.inc.

413  {
414  return preg_match("/".$this->pattern."/", $key);
415  }

◆ get()

WCCache::get (   $key)

Definition at line 368 of file cache.inc.

369  {
370  $value = wincache_ucache_get($key, $success);
371  if (!$success) return null;
372 
373  return unserialize($value);
374  }

◆ invalidate()

WCCache::invalidate (   $key)

Definition at line 381 of file cache.inc.

382  {
383  return wincache_ucache_delete($key);
384  }

◆ invalidateMatching()

WCCache::invalidateMatching (   $pattern)

Definition at line 386 of file cache.inc.

387  {
388  $this->pattern = $pattern;
389 
390  $info = wincache_ucache_info();
391 
392  $keys = array();
393 
394  foreach($info['ucache_entries'] as $entry)
395  {
396  $keys[] = $entry['key_name'];
397  }
398  $doomedKeys = array_filter($keys, array($this, filterKey));
399 
400  foreach($doomedKeys as $key)
401  {
402  $this->invalidate($key);
403  }
404 
405  unset($this->pattern);
406  }
invalidate($key)
Definition: cache.inc:381
filterKey($key)
Internal callback function that supports the invalidateMatching function.
Definition: cache.inc:412

◆ put()

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

Definition at line 376 of file cache.inc.

377  {
378  return wincache_ucache_set($key, serialize($obj), $ttl);
379  }

◆ WCCache()

WCCache::WCCache ( )

Definition at line 363 of file cache.inc.

364  {
365  trace("Creating WinCache cache", 4);
366  }
trace($msg, $lvl=3, $callStack=null)
Send output to the trace log.
Definition: functions.inc:1010

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