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 / Advanced / Constants

Show “$cache”             Show Arguments        

Common

NameReturnSummary 
$cache->delete(string $name)
boolDelete/clear the cache(s) identified by given name or wildcard
$cache->deleteFor(string $ns)
boolDelete one or more caches in a given namespace
$cache->get($name)
string, array, PageArray, mixed or nullGet data from cache with given name
$cache->getFor($ns, string $name)
string, array, PageArray, mixed or nullSame as get() but with namespace
$cache->save(string $name, $data)
boolSave data to cache with given name
$cache->saveFor($ns, string $name, $data)
boolSame as save() except with namespace

Advanced

NameReturnSummary 
$cache->getInfo()
arrayGet information about all the caches in this WireCache
$cache->maintenance()
boolCache 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

Constants

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

NameReturnSummary 
WireCache::expireDaily const86400Cache should expire once per day
WireCache::expireHourly const3600Cache should expire once per hour
WireCache::expireMonthly const2419200Cache should expire once per month
WireCache::expireNever const2010-04-08 03:10:10Cache should never expire (unless manually cleared).
WireCache::expireNow const0Cache should expire now
WireCache::expireSave const2010-01-01 01:01:01Cache should expire when a given resource (Page or Template) is saved.
WireCache::expireWeekly const604800Cache 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:

API reference based on ProcessWire core version 3.0.84