public static byte[] numToBytes(long value) { return numToBytes(value, false); }
private static int _toposint(byte[] offset1) throws RedisException { long offset = bytesToNum(offset1); if (offset < 0 || offset > MAX_VALUE) { throw notInteger(); } return (int) offset; }
public static byte[] numToBytes(long value, boolean withCRLF) { if (value >= 0 && value < NUM_MAP_LENGTH) { int index = (int) value; return withCRLF ? numMapWithCRLF[index] : numMap[index]; } else if (value == -1) { return withCRLF ? NEG_ONE_WITH_CRLF : NEG_ONE; } return convert(value, withCRLF); }
private IntegerReply _change(byte[] key0, long delta) throws RedisException { Object o = _get(key0); if (o == null) { _put(key0, numToBytes(delta, false)); return integer(delta); } else if (o instanceof byte[]) { try { long integer = bytesToNum((byte[]) o) + delta; _put(key0, numToBytes(integer, false)); return integer(integer); } catch (IllegalArgumentException e) { throw new RedisException(e.getMessage()); } } else { throw notInteger(); } }
private IntegerReply _change(byte[] key0, long delta) throws RedisException { Object o = _get(key0); if (o == null) { _put(key0, numToBytes(delta, false)); return integer(delta); } else if (o instanceof byte[]) { try { long integer = bytesToNum((byte[]) o) + delta; _put(key0, numToBytes(integer, false)); return integer(integer); } catch (IllegalArgumentException e) { throw new RedisException(e.getMessage()); } } else { throw notInteger(); } }
@Override public void write(ByteBuf os) throws IOException { os.writeByte(MARKER); os.writeBytes(numToBytes(integer, true)); }
private static int _toint(byte[] offset1) throws RedisException { long offset = bytesToNum(offset1); if (offset > MAX_VALUE) { throw notInteger(); } return (int) offset; }
@Override public void write(ByteBuf os) throws IOException { os.writeByte(MARKER); os.writeBytes(numToBytes(capacity, true)); if (capacity > 0) { os.writeBytes(bytes); os.writeBytes(CRLF); } }
private static int _torange(byte[] offset1, int length) throws RedisException { long offset = bytesToNum(offset1); if (offset > MAX_VALUE) { throw notInteger(); } if (offset < 0) { offset = (length + offset); } if (offset >= length) { offset = length - 1; } return (int) offset; }
private static void writeArgument(ByteBuf os, ByteBuf argument) throws IOException { os.writeBytes(BYTES_PREFIX); os.writeBytes(numToBytes(argument.readableBytes(), true)); os.writeBytes(argument); os.writeBytes(CRLF); }
/** * Decrement the integer value of a key by the given number * String * * @param key0 * @param decrement1 * @return IntegerReply */ @Override public IntegerReply decrby(byte[] key0, byte[] decrement1) throws RedisException { return _change(key0, -bytesToNum(decrement1)); }
private static void writeArgument(OutputStream os, byte[] argument) throws IOException { os.write(BYTES_PREFIX); os.write(numToBytes(argument.length, true)); os.write(argument); os.write(CRLF); }
private static int _toposint(byte[] offset1) throws RedisException { long offset = bytesToNum(offset1); if (offset < 0 || offset > MAX_VALUE) { throw notInteger(); } return (int) offset; }
private static void writeArgument(ByteBuf os, byte[] argument) throws IOException { os.writeBytes(BYTES_PREFIX); os.writeBytes(numToBytes(argument.length, true)); os.writeBytes(argument); os.writeBytes(CRLF); }
private static int _toint(byte[] offset1) throws RedisException { long offset = bytesToNum(offset1); if (offset > MAX_VALUE) { throw notInteger(); } return (int) offset; }
private static void writeArgument(ByteBuf os, byte[] argument) throws IOException { os.writeBytes(BYTES_PREFIX); os.writeBytes(numToBytes(argument.length, true)); os.writeBytes(argument); os.writeBytes(CRLF); }
/** * Decrement the integer value of a key by the given number * String * * @param key0 * @param decrement1 * @return IntegerReply */ @Override public IntegerReply decrby(byte[] key0, byte[] decrement1) throws RedisException { return _change(key0, -bytesToNum(decrement1)); }
private static void writeArgument(OutputStream os, byte[] argument) throws IOException { os.write(BYTES_PREFIX); os.write(numToBytes(argument.length, true)); os.write(argument); os.write(CRLF); }
/** * Increment the integer value of a key by the given amount * String * * @param key0 * @param increment1 * @return IntegerReply */ @Override public IntegerReply incrby(byte[] key0, byte[] increment1) throws RedisException { return _change(key0, bytesToNum(increment1)); }
private static void writeArgument(OutputStream os, byte[] argument) throws IOException { os.write(BYTES_PREFIX); os.write(numToBytes(argument.length, true)); os.write(argument); os.write(CRLF); }