yinqiwen / ardb

A redis protocol compatible nosql, it support multiple storage engines as backend like Google's LevelDB, Facebook's RocksDB, OpenLDAP's LMDB, PerconaFT, WiredTiger, ForestDB.
BSD 3-Clause "New" or "Revised" License
1.83k stars 278 forks source link

Redis Inconsistencies: Hdel/expire doesn't delete the parent container when elements hit 0 #442

Open Lssikkes opened 6 years ago

Lssikkes commented 6 years ago

I'm building unit tests for the database to gauge how well Ardb matches Redis semantics, but it seems like I'm hitting an issue where a hash container is not cleared automatically when the amount of elements hit 0, or the timeout is hit (which is default redis behavior for every container, except redis 5.0 streams).

To reproduce

> hset test a 1
> hdel test a
> exists test
  shows: 1 expected: 0 (which is what redis will output)

same situation with expire:

> hset test a 1
> expire test 1
_<after a second>_
> exists 1
  shows: 1 expected: 0
> keys test
  shows: "test" expected: (empty list or set)
> ttl test
  shows: -1 expected: -2
> hget test a
  shows: 1 expected: (nil)

I hope I can work around these inconsistencies for the time being, but I would greatly appreciate a proper fix for this problem.. Willing to buy some ko-fi for you for the work ;)

yinqiwen commented 6 years ago
  1. for hset/hdel, u need to change redis-compatible-mode to yes in ardb.conf
  2. for the issue exists after expire, currently exists/keys/ttl does not check the key expire or not, there is a background task to do the expire work. this can be improved later.