Method
Cache::has
Whether a value is stored under $key and has not expired.
Description#
public Cache::has(
$key
): boolParameters#
- $key
Return values#
bool
Errors / Exceptions#
| Exception | When |
|---|---|
CacheKeyException | For an invalid key |
Examples#
use Swerve\Swerve;
phasync::run(function () {
$cache = Swerve::cache();
$cache->set('nothing', null);
var_dump($cache->has('nothing')); // stored, with the value null
var_dump($cache->has('never-set'));
var_dump($cache->get('nothing', 'default'));
});Output
bool(true) bool(false) NULL