public boolean equals(Object o) { return o instanceof BytesKey && equals(bytes, ((BytesKey) o).bytes); }
/** * Remove and get the first element in a list * List * * @param key0 * @return BulkReply */ @Override public BulkReply lpop(byte[] key0) throws RedisException { List<BytesValue> list = _getlist(key0, false); if (list == null || list.size() == 0) { return NIL_REPLY; } else { return new BulkReply(list.remove(0).getBytes()); } }
if (list.get(i).equals(value)) { list.remove(i); e -= dir;
/** * Remove and get the first element in a list * List * * @param key0 * @return BulkReply */ @Override public BulkReply lpop(byte[] key0) throws RedisException { List<BytesValue> list = _getlist(key0, false); if (list == null || list.size() == 0) { return NIL_REPLY; } else { return new BulkReply(list.remove(0).getBytes()); } }
if (list.get(i).equals(value)) { list.remove(i); e -= dir;
/** * Remove and get the last element in a list * List * * @param key0 * @return BulkReply */ @Override public BulkReply rpop(byte[] key0) throws RedisException { List<BytesValue> list = _getlist(key0, false); int l; if (list == null || (l = list.size()) == 0) { return NIL_REPLY; } else { byte[] bytes = list.get(l - 1).getBytes(); list.remove(l - 1); return new BulkReply(bytes); } }
/** * Remove and get the last element in a list * List * * @param key0 * @return BulkReply */ @Override public BulkReply rpop(byte[] key0) throws RedisException { List<BytesValue> list = _getlist(key0, false); int l; if (list == null || (l = list.size()) == 0) { return NIL_REPLY; } else { byte[] bytes = list.get(l - 1).getBytes(); list.remove(l - 1); return new BulkReply(bytes); } }
/** * Remove the last element in a list, append it to another list and return it * List * * @param source0 * @param destination1 * @return BulkReply */ @Override public BulkReply rpoplpush(byte[] source0, byte[] destination1) throws RedisException { List<BytesValue> source = _getlist(source0, false); int l; if (source == null || (l = source.size()) == 0) { return NIL_REPLY; } else { List<BytesValue> dest = _getlist(destination1, true); BytesValue popped = source.get(l - 1); source.remove(l - 1); dest.add(0, popped); return new BulkReply(popped.getBytes()); } }
/** * Remove the last element in a list, append it to another list and return it * List * * @param source0 * @param destination1 * @return BulkReply */ @Override public BulkReply rpoplpush(byte[] source0, byte[] destination1) throws RedisException { List<BytesValue> source = _getlist(source0, false); int l; if (source == null || (l = source.size()) == 0) { return NIL_REPLY; } else { List<BytesValue> dest = _getlist(destination1, true); BytesValue popped = source.get(l - 1); source.remove(l - 1); dest.add(0, popped); return new BulkReply(popped.getBytes()); } }
/** * Get an element from a list by its index * List * * @param key0 * @param index1 * @return BulkReply */ @SuppressWarnings("unchecked") @Override public BulkReply lindex(byte[] key0, byte[] index1) throws RedisException { int index = _toposint(index1); List<BytesValue> list = _getlist(key0, true); if (list == null || list.size() <= index) { return NIL_REPLY; } else { return new BulkReply(list.get(index).getBytes()); } }
/** * Get an element from a list by its index * List * * @param key0 * @param index1 * @return BulkReply */ @SuppressWarnings("unchecked") @Override public BulkReply lindex(byte[] key0, byte[] index1) throws RedisException { int index = _toposint(index1); List<BytesValue> list = _getlist(key0, true); if (list == null || list.size() <= index) { return NIL_REPLY; } else { return new BulkReply(list.get(index).getBytes()); } }
/** * Get a range of elements from a list * List * * @param key0 * @param start1 * @param stop2 * @return MultiBulkReply */ @Override public MultiBulkReply lrange(byte[] key0, byte[] start1, byte[] stop2) throws RedisException { List<BytesValue> list = _getlist(key0, false); if (list == null) { return MultiBulkReply.EMPTY; } else { int size = list.size(); int s = _torange(start1, size); int e = _torange(stop2, size); if (e < s) e = s; int length = e - s + 1; Reply[] replies = new Reply[length]; for (int i = s; i <= e; i++) { replies[i - s] = new BulkReply(list.get(i).getBytes()); } return new MultiBulkReply(replies); } }
/** * Get a range of elements from a list * List * * @param key0 * @param start1 * @param stop2 * @return MultiBulkReply */ @Override public MultiBulkReply lrange(byte[] key0, byte[] start1, byte[] stop2) throws RedisException { List<BytesValue> list = _getlist(key0, false); if (list == null) { return MultiBulkReply.EMPTY; } else { int size = list.size(); int s = _torange(start1, size); int e = _torange(stop2, size); if (e < s) e = s; int length = e - s + 1; Reply[] replies = new Reply[length]; for (int i = s; i <= e; i++) { replies[i - s] = new BulkReply(list.get(i).getBytes()); } return new MultiBulkReply(replies); } }