Method
Cache::setMultiple
Store several values, by key, with one $ttl, as Cache::set does.
Description#
public Cache::setMultiple(
$values,
$ttl = null
): boolParameters#
- $values
- $ttl = null
- Seconds, an interval, or null for no expiry; zero or less deletes the keys
Return values#
False when a value is larger than the cache holds bool
Errors / Exceptions#
| Exception | When |
|---|---|
CacheKeyException | For an invalid key |
LogicException | Directly in swerve.php, which the worker serves after: a coroutine started there waits instead |
Examples#
use Swerve\Swerve;
phasync::run(function () {
$cache = Swerve::cache();
$cache->setMultiple(['a' => 1, 'b' => 2, 'c' => 3], new DateInterval('PT5M')); // one ttl for all
var_export($cache->getMultiple(['a', 'b', 'x'], 'none'));
echo "\n";
});Output
array ( 'a' => 1, 'b' => 2, 'x' => 'none', )