isamu / rocksdb-ruby

A simple RocksDB library for Ruby
MIT License
75 stars 24 forks source link

db.exists? return always true #34

Open sebthemonster opened 1 year ago

sebthemonster commented 1 year ago

I found a bug in the gem when trying to check for the existence of a key right after opening the database. Here are examples of the bug, in the IRB console :

db = RocksDB.open("db/path")

db.exists?("user:adadada") # must return false
> true

db.get("user:adadada")  # must return nil
> nil

db.exists?("user:adadada") # must return false
> false

But if before asking for the existence of the key, we do an each_key or other, db.exists? works well :

db = RocksDB.open("db/path")
db.each_key { |k| puts k }
db.exists?("user:adadada") # must return false
> false