moneta-rb / moneta

a unified interface to key/value stores
https://github.com/moneta-rb/moneta
MIT License
1.12k stars 87 forks source link

Redis: DELETE on a non-existent key causes a method call on a nil #240

Closed aks closed 1 year ago

aks commented 1 year ago

Calling DELETE on a missing key returns a nil, which then gets sent the value method.

The result of delete on a missing key should just be nil.

See https://github.com/moneta-rb/moneta/pull/239

asppsa commented 1 year ago

Thanks for the report! I'm not able to reproduce the issue using the test case you supplied in #239 though:

irb(main):002:0> Moneta::Adapters::Redis.new.delete('non_existent_key')
=> nil

This is using the main branch with Ruby 3 and v4.8 of the redis gem. Maybe there is some other prerequistite needed for the future to be nil, like a connection failure or something?

The docs for futures are here - my understanding from reading them is that pipeline.get will return a future object no matter what (like a promise in JS).

asppsa commented 1 year ago

Closing this one for now. Can reopen if we get more info.