jedis icon indicating copy to clipboard operation
jedis copied to clipboard

Use only 'int' or only 'long' for offsets and counts

Open sazzad16 opened this issue 3 years ago • 3 comments

Jedis alternatively uses int and long while receiving offset, count and similar parameters. We should change it to consistently use either one of those. Which one should it be?

Here is a list of methods that I have picked from JedisCommands.java (which I think is a good representative of all implementations).

  • List<String> hrandfield(String key, long count);
  • Map<String, String> hrandfieldWithValues(String key, long count);
  • List<String> lrange(String key, long start, long stop);
  • String ltrim(String key, long start, long stop);
  • String lindex(String key, long index);
  • String lset(String key, long index, String value);
  • Long lrem(String key, long count, String value);
  • List<String> lpop(String key, int count);
  • List<Long> lpos(String key, String element, LPosParams params, long count);
  • List<String> rpop(String key, int count);
  • Set<String> spop(String key, long count);
  • List<String> srandmember(String key, int count);
  • Set<String> zrange(String key, long start, long stop);
  • Set<String> zrevrange(String key, long start, long stop);
  • Set<Tuple> zrangeWithScores(String key, long start, long stop);
  • Set<Tuple> zrevrangeWithScores(String key, long start, long stop);
  • Set<String> zrandmember(String key, long count);
  • Set<Tuple> zrandmemberWithScores(String key, long count);
  • Set<Tuple> zpopmax(String key, int count);
  • Set<Tuple> zpopmin(String key, int count);
  • Set<String> zrangeByScore(String key, double min, double max, int offset, int count);
  • Set<String> zrangeByScore(String key, String min, String max, int offset, int count);
  • Set<String> zrevrangeByScore(String key, double max, double min, int offset, int count);
  • Set<Tuple> zrangeByScoreWithScores(String key, double min, double max, int offset, int count);
  • Set<String> zrevrangeByScore(String key, String max, String min, int offset, int count);
  • Set<Tuple> zrangeByScoreWithScores(String key, String min, String max, int offset, int count);
  • Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min, int offset, int count);
  • Set<Tuple> zrevrangeByScoreWithScores(String key, String max, String min, int offset, int count);
  • Long zremrangeByRank(String key, long start, long stop);
  • Set<String> zrangeByLex(String key, String min, String max, int offset, int count);
  • Set<String> zrevrangeByLex(String key, String max, String min, int offset, int count);
  • StreamEntryID xadd(String key, StreamEntryID id, Map<String, String> hash, long maxLen, boolean approximateLength);
  • List<StreamEntry> xrange(String key, StreamEntryID start, StreamEntryID end, int count);
  • List<StreamEntry> xrevrange(String key, StreamEntryID end, StreamEntryID start, int count);
  • List<StreamPendingEntry> xpending(String key, String groupname, StreamEntryID start, StreamEntryID end, int count, String consumername);
  • long xtrim( String key, long maxLen, boolean approximate);

sazzad16 avatar May 12 '21 12:05 sazzad16

@gkorland @dengliming @mina-asham @yangbodong22011 PING!

sazzad16 avatar May 12 '21 12:05 sazzad16

I don't think the righ goal is to be consistent between int/long regardless here, but rather be consistent with the Redis server implementation, should we just go through each of those and verify what's the redis range here (I believe it uses long for all of these based on some vague memory, but I haven't actually verified).

mina-asham avatar May 12 '21 12:05 mina-asham

I don't think the righ goal is to be consistent between int/long regardless here, but rather be consistent with the Redis server implementation, should we just go through each of those and verify what's the redis range here (I believe it uses long for all of these based on some vague memory, but I haven't actually verified).

I have determined that these command parameters should all be long, and there is a bug in using int at present, So we can change it to long.

p.s. Determined all redis version

List lpop(String key, int count);
List rpop(String key, int count);
List srandmember(String key, int count);
Set zpopmax(String key, int count);
Set zpopmin(String key, int count);
Set zrangeByScore(String key, double min, double max, int offset, int count);
Set zrangeByScore(String key, String min, String max, int offset, int count);
Set zrevrangeByScore(String key, double max, double min, int offset, int count);
Set zrangeByScoreWithScores(String key, double min, double max, int offset, int count);
Set zrevrangeByScore(String key, String max, String min, int offset, int count);
Set zrangeByScoreWithScores(String key, String min, String max, int offset, int count);
Set zrevrangeByScoreWithScores(String key, double max, double min, int offset, int count);
Set zrevrangeByScoreWithScores(String key, String max, String min, int offset, int count);
Set zrangeByLex(String key, String min, String max, int offset, int count);
Set zrevrangeByLex(String key, String max, String min, int offset, int count);
List xrange(String key, StreamEntryID start, StreamEntryID end, int count);
List xrevrange(String key, StreamEntryID end, StreamEntryID start, int count);
List xpending(String key, String groupname, StreamEntryID start, StreamEntryID end, int count, String consumername);

yangbodong22011 avatar May 13 '21 02:05 yangbodong22011