2013-03-05 114 views

回答

31

在這裏你可以看到Redis命令此資料庫中node_redis github

工作正如你可以看到「刪除」命令是在列表中。

這個命令允許你從Jonatan回答的時候刪除選定數據庫中的鍵。

+0

@Elephant hdel不存在,但它的工作原理。該參考應該是https://redis.io/commands,因爲「它支持所有的Redis命令」(引自github https://github.com/NodeRedis/node_redis)。 – TigOldBitties 2017-01-26 08:50:19

+0

@Elephant從來沒有,我在看ioredis https://github.com/luin/ioredis/blob/master/lib/command.js – TigOldBitties 2017-01-30 08:17:41

12

如果我正確記得的東西,del應該這樣做。

34

可以del使用這樣的:

redis.del('SampleKey'); 
+0

這是實際的答案,給出了一個鏈接到redis文檔不是一個答案,該問題被標記爲'node-redis' – Sandwich 2017-10-26 11:18:10

3

正如以上的人都已經表示可以使用刪除功能。您可以使用此語法確保成功刪除操作。

client.del('dummyvalue', function(err, response) { 
    if (response == 1) { 
     console.log("Deleted Successfully!") 
    } else{ 
    console.log("Cannot delete") 
    } 
}) 

因爲DEL命令將返回(integer) 1成功操作。

redis 127.0.0.1:6379> DEL key 
    Success: (integer) 1 
    Unsuccess: (integer) 0