D
D
Dmitry2020-03-26 14:27:20
PHP
Dmitry, 2020-03-26 14:27:20

How to delete hMGet all data?

Hello!
I put the values ​​in redis:

$redis->hMGet("REDIS_BIG_KEY", ['1999'=>1,'2000'=>2]);

How to remove all REDIS_BIG_KEY hash values?
I try $redis->del('REDIS_BIG_KEY')
It cleans only the values ​​for me, and leaves the keys, I get:
['1999'=>false,'2000'=>false]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2020-03-26
@Nc_Soft

https://redis.io/commands/del
Everything is fine deleted

<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis->hSet("REDIS_BIG_KEY", 1991, 1);
$redis->hSet("REDIS_BIG_KEY", 1992, 2);

var_dump($redis->hGetAll('REDIS_BIG_KEY'));
$redis->del('REDIS_BIG_KEY');
var_dump($redis->hGetAll('REDIS_BIG_KEY'));
/*
array(2) {
  [1991]=>
  string(1) "1"
  [1992]=>
  string(1) "2"
}
array(0) {
}
*/

I also tested through redis-cli
127.0.0.1:6379> hgetall REDIS_BIG_KEY
1) "1991"
2) "1"
3) "1992"
4) "2"
127.0.0.1:6379> hgetall REDIS_BIG_KEY
(empty list or set)
127.0.0.1:6379>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question