Provides easy, persistent caching of markup, strings, arrays or PageArray objects.

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the WireCache class also inherits all the methods and properties of: Wire.

Common / Constants

Common

Name Return Summary  
$cache->delete(string $name) bool Delete/clear the cache(s) identified by $name
$cache->deleteFor(string $ns) bool Delete the cache identified by $name within given namespace ($ns)
$cache->get($name) string, array, PageArray, mixed or null Get data from cache with given name
$cache->getFor($ns, string $name) string or array Same as get() but with namespace
$cache->getInfo() array Get information about all the caches in this WireCache
$cache->log() WireLog Save to the cache log
$cache->maintenance() bool Cache maintenance removes expired caches
$cache->preload(array $names) (nothing) Preload the given caches, so that they will be returned without query on the next get() call
$cache->preloadFor($ns) (nothing) Preload all caches for the given object or namespace
$cache->save(string $name, $data) bool Save data to cache with given name
$cache->saveFor($ns, string $name, $data) bool Same as save() except with namespace

Constants

These constants are used for the $expire argument of get() and save() cache methods.

Name Return Summary  
WireCache::expireDaily const 86400 Cache should expire once per day
WireCache::expireHourly const 3600 Cache should expire once per hour
WireCache::expireMonthly const 2419200 Cache should expire once per month
WireCache::expireNever const 2010-04-08 03:10:10 Cache should never expire (unless manually cleared).
WireCache::expireNow const 0 Cache should expire now
WireCache::expireSave const 2010-01-01 01:01:01 Cache should expire when a given resource (Page or Template) is saved.
WireCache::expireWeekly const 604800 Cache should expire once per week

Additional methods and properties

In addition to the methods and properties above, WireCache also inherits the methods and properties of these classes: