$cache→saveFor()
Same as save() except with namespace
Namespace is useful to avoid cache name collisions. The ProcessWire core commonly uses cache namespace to bind cache values to the object class, which often make a good namespace.
Example
// save cache using manually specified namespace
$cache->save("my-namespace", "my-cache-name", $value);
// save cache using namespace of current object
$cache->save($this, "my-cache-name", $value);
Usage
// basic usage
$bool = $cache->saveFor($ns, string $name, $data);
// usage with all arguments
$bool = $cache->saveFor($ns, string $name, $data, $expire = 86400);
Arguments
Name | Type(s) | Description |
---|---|---|
$ns | string object | Namespace for cache |
$name | string | Name of cache, can be any string up to 255 chars |
$data | string array PageArray | Data that you want to cache |
$expire (optional) | int Page | Lifetime of this cache, in seconds, OR one of the following:
|
Return value
bool
Returns true if cache was successful, false if not
API reference based on ProcessWire core version 3.0.251