Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

键删除问题 #35

Open
iKenApple opened this issue Aug 2, 2017 · 2 comments
Open

键删除问题 #35

iKenApple opened this issue Aug 2, 2017 · 2 comments

Comments

@iKenApple
Copy link

del在删除字符串类型key的时候没有问题,但是删除hash类型key的时候,无法删除。
原因是:
hash键值存储在leveldb的形式是:

  • \xFF\x01[key]\x01 1
  • \xFF\x01[key]\x01[field] value
    ds_delete和rl_delet实现中,没有区分key的类型,均是根据key直接删除,对于hash值的删除肯定不成功。
    觉得hash类型key的删除可以借鉴ds_hgetall方法。

期待回复,谢谢

@rchunping
Copy link
Contributor

rchunping commented Aug 2, 2017

用 ds_hdel

ds_hdel <KEY>   删除整个hash
ds_hdel <KEY> <FIELD>  删除某个 field
ds_hdel <KEY> <FIELD_1> <FIELD_2>  删除多个 fields

https://github.com/qiye/redis-storage/blob/master/src/ds.c#L1874

@iKenApple
Copy link
Author

谢谢回复。

感觉这样缩小了del的使用范围,可能会带来隐患。建议在文档中说明一下吧。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants