Skip to content

Redis::exists should no longer use Boolify #698

@scottyschup

Description

@scottyschup

In the Redis documentation for exists, as of Redis 3.0.3 exists may take multiple key names and returns a count of the number of keys that exist.

Using the redis-rb gem v3.3.3, the result of Redis::exists with an array of keys returns true if and only if just one of the keys exist. false is returned if none of the keys exist or if multiple keys do because Boolify looks for a non-nil value equal to 1.

To reproduce:

r = Redis.new
r.mset 'test1', 1, 'test2', 2
r.exists ['test1', 'nonexistant']
#=> true
r.exists ['test1', 'test2']
#=> false

So either Boolify could be adjusted to look for values >= 1, or (what makes more sense to me) Boolify should not be used in this function so that the return value is the count of the number of keys found as is described in the Redis docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions