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

Add mexists method that allow to check the existance of multiple keys #873

Conversation

GustavoCaso
Copy link
Contributor

@GustavoCaso GustavoCaso commented Sep 16, 2019

When calling exists with multiple keys, the return value depending on the arguments could be either a Boolean or an Integer.

This PR aims to fix that by creating a new method called mexists that accepts an array of keys

Example of exists

redis.set("foo", "world")
=> "OK"
[3] pry(main)> redis.exists(['foo', 'foo2'])
=> true
[4] pry(main)> redis.exists(['foo3', 'foo2'])
=> false
[5] pry(main)> redis.exists(['foo', 'foo2'])
=> true
[6] pry(main)> redis.set('foo2', 'world')
=> "OK"
[7] pry(main)> redis.exists(['foo', 'foo2'])
=> 2

Example of exists

redis.set("foo", "world")
=> "OK"
[3] pry(main)> redis.mexists(['foo', 'foo2'])
=> 1
[4] pry(main)> redis.exists(['foo3', 'foo2'])
=> 0
[5] pry(main)> redis.set('foo2', 'world')
=> "OK"
[7] pry(main)> redis.exists(['foo', 'foo2'])
=> 2

@rafaelfranca
Copy link
Collaborator

Tests are broken. Can you take a look?

@byroot
Copy link
Collaborator

byroot commented Sep 16, 2019

There's also a backward compatibility concern here, I think that's why previous similar PRs stalled:

of multiple keys

It will return a Fixnum indicating how many keys exists
@GustavoCaso GustavoCaso force-pushed the return-integer-value-for-exists-and-multiple-keys branch from aa5b22d to b0528a4 Compare September 19, 2019 11:06
@GustavoCaso GustavoCaso changed the title return integer value for exists and multiple keys Add mexists method that allow to check the existance of multiple keys Sep 19, 2019
@byroot
Copy link
Collaborator

byroot commented Sep 19, 2019

@GustavoCaso the CI failure is legit (mexist keys hashing to different servers)

@GustavoCaso
Copy link
Contributor Author

Looking into it

@byroot
Copy link
Collaborator

byroot commented Jun 9, 2020

Fixed in 3257527

@byroot byroot closed this Jun 9, 2020
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

Successfully merging this pull request may close these issues.

None yet

3 participants