phasync
Cache / clear

Method

Cache::clear

Remove everything from the cache of every worker.

Description#

public Cache::clear(): bool

Return values#

bool

Errors / Exceptions#

ExceptionWhen
LogicExceptionDirectly in swerve.php, which the worker serves after: a coroutine started there waits instead

Examples#

Example 1Empty the cache
use Swerve\Swerve;

phasync::run(function () {
    $cache = Swerve::cache();
    $cache->setMultiple(['a' => 1, 'b' => 2]);

    $cache->clear();                          // everything, in every worker

    var_export($cache->getMultiple(['a', 'b']));
    echo "\n";
});
Output
array (
  'a' => NULL,
  'b' => NULL,
)