David Costa Faidella
David Costa Faidella

Reputation: 305

Jedis Changing the semantics of Redis?

So, Redis specify the zrange (and related sorted set commands) as an ORDERED set of results (a list without duplicates perhaps?).

Why then the zrange (and related APIs) on Jedis (Official and Recommended REDIS client) return a Set??? Which has, by definition, no concept of ordering?

That is a direct violation of the semantics of the redis operations.

This is the zrange jedis 2.0.0 implementation:


  public Set<byte[]> zrange(final byte[] key, final int start, final int end) {
        checkIsInMulti();
        client.zrange(key, start, end);
        final List<byte[]> members = client.getBinaryMultiBulkReply();
        return new LinkedHashSet<byte[]>(members);
    } 

Jedis contributors, are you planning to fix it?

Upvotes: 3

Views: 683

Answers (2)

Ivo
Ivo

Reputation: 8352

In version 2.2.0 it will be returning SorteSet, according to https://github.com/xetorthio/jedis/issues/244

Upvotes: 1

Eric Hauser
Eric Hauser

Reputation: 5581

A LinkedHashSet is an ordered set. The API should probably be changed to reflect that explicitly or just return a list.

This conversation is better suited for the mailing list as opposed to SO.

Upvotes: 1

Related Questions