Mirakurun Mirakurun - 5 months ago 28
PHP Question

Redis in PHP: keys "*"

I have searched the Internet up and down, but couldn't find the command how to get all keys from Redis db in php.

Example:

$redis->connect
$redis->hset


When I type
keys "*"
in redis-cli, I get all the keys which are stored in db.

Output:

tenshi@mashiro:~$ redis-cli
127.0.0.1:6379> keys *
1) "Testserver"
2) "testserver"
3) "Server5"


Now I want the similar command in php.

Answer

If you're using the PHP extension for redis, then the command is $redis->keys('*')