Reputation: 176
I am using predis library to cache the data. I am able to delete the cache individually using
$redis->cache->hdel(self::$cacheNamespace, $key);
But i need to delete all the cache without providing any keys, Is there a way to achieve that in predis.
Upvotes: 3
Views: 14744
Reputation: 6519
There two flush functions. One of them for all Redis databases, another is only for specific Redis db. Use them like;
flushAll()
Description: Remove all keys from all databases.
Parameters async (bool) requires server version 4.0.0 or greater
Return value BOOL: Always TRUE.
Example
$redis->flushAll();
flushDb()
Description: Remove all keys from the current database.
Parameters async (bool) requires server version 4.0.0 or greater
Return value BOOL: Always TRUE.
Example
$redis->flushDb();
Source: https://github.com/phpredis/phpredis#flushdb
Upvotes: 0
Reputation: 15775
PHP Method Predis\Client::flushAll Code Examples
predis equivalent of redis-cli FLUSHALL
public function flushAll()
{
$this->_redis->flushAll();
}
Upvotes: 2