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

key.delete always returns okay - whether or not the key exists #251

Open
chayim opened this issue Dec 1, 2022 · 3 comments
Open

key.delete always returns okay - whether or not the key exists #251

chayim opened this issue Dec 1, 2022 · 3 comments
Labels
breakingchange bug Something isn't working good first issue Good for newcomers

Comments

@chayim
Copy link
Contributor

chayim commented Dec 1, 2022

In redis, when deleting a key that exists, a 1 is always returned.

127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> del foo
(integer) 1
127.0.0.1:6379> 

When delete a key that does not exist, a 0 is always returned.

127.0.0.1:6379> keys *
(empty array)
127.0.0.1:6379> del foo
(integer) 0
127.0.0.1:6379> 

Due to this line redismodule-rs always returns okay, on the delete of a key.

This also appears true for unlink unlink.

We should probably return either an OK/Error combination, or ints like Redis, but not always OK.

@oshadmi
Copy link
Contributor

oshadmi commented Dec 1, 2022

It seems a "breaking" change (not backward compatible)
(there's no such label yet)

@oshadmi oshadmi added bug Something isn't working good first issue Good for newcomers labels Dec 1, 2022
@chayim
Copy link
Contributor Author

chayim commented Dec 4, 2022

Any preference on which? As a reference, redis-py and jedis copy the behaviour of the redis-cli and returns an int - so I'd vote for an int here.

@oshadmi
Copy link
Contributor

oshadmi commented Dec 4, 2022

@chayim I suggest returning Status (for example, see hash_del)
(actually returningREDISMODULE_OK for int 0 and REDISMODULE_ERR for int 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breakingchange bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants