该命令用于在 key 存在是删除 key。
删除指定的键。
Parameters:
array|int|string $key1 一个键数组,或一个未定义数量的参数,每个键:key1 key2 key3…keyN
int|string $otherKeys
Returns:
删除的键数
Declared in: Redis
Links: https://redis.io/commands/del
Source:
S:/Software/JetBrains/PHPStorm/App/PhpStorm-2020.2.1.win/plugins/php/lib/php.jar!/stubs/redis/Redis.phpdel
on redis.io
<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('10.1.3.15', 6379);
$redis->auth('kuaicdn_redis_passwd');
$redis->flushAll();
$ret['exec'][]=$redis->mset(array(
'list_test1'=>'value1',
'list_test2'=>'value2',
'list_test3'=>'value3',
));
$ret['ret'][]=$redis->mget(array(
'list_test1',
'list_test2',
'list_test3'
));
$ret['exec'][]=$redis->del('list_test2');
$ret['ret'][]=$redis->mget(array(
'list_test1',
'list_test2',
'list_test3'
));
print_r($ret);
?>
返回值:
Array
(
[exec] => Array
(
[0] => 1
[1] => 1
)
[ret] => Array
(
[0] => Array
(
[0] => value1
[1] => value2
[2] => value3
)
[1] => Array
(
[0] => value1
[1] =>
[2] => value3
)
)
)