我需要刪除含有一些特殊鍵的鍵(在我的情況方括號中):PHP Predis:如何獲取/刪除包含特殊字符的鍵?
我這樣做,但它不工作:
$this->redis;
$keys = $this->redis->keys("*");
foreach ($keys as $key) {
// keys are in the following format:
// vir3_data_cache[zones_cdc_shifting_series_2013_5][1]
$this->redis->del($key);
// no key was deleted
}
我也試圖引用的關鍵,但沒有成功:
$this->redis;
$keys = $this->redis->keys("*");
foreach ($keys as $key) {
// keys are in the following format:
// vir3_data_cache[zones_cdc_shifting_series_2013_5][1]
$quotedKey = addslashes(addslashes($key));
$this->redis->del($quotedKey);
// no key was deleted
}
我沒有看到這些不同。 – nmallare 2014-08-27 17:09:01
感謝@nmallare我剛剛糾正了第二個阻止 – fdellutri 2014-08-27 17:21:13
嘗試在'''而不是'''包裝你的密鑰 – nmallare 2014-08-28 22:03:52