/** * 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)); }
/** * 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)); }
/** * 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 int _toposint(byte[] offset1) throws RedisException { long offset = bytesToNum(offset1); if (offset < 0 || offset > MAX_VALUE) { throw notInteger(); } return (int) offset; }
private static int _toint(byte[] offset1) throws RedisException { long offset = bytesToNum(offset1); if (offset > MAX_VALUE) { throw notInteger(); } return (int) offset; }
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 int _toint(byte[] offset1) throws RedisException { long offset = bytesToNum(offset1); if (offset > MAX_VALUE) { throw notInteger(); } return (int) offset; }
/** * 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 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 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; }
/** * Set the value and expiration of a key * String * * @param key0 * @param seconds1 * @param value2 * @return StatusReply */ @Override public StatusReply setex(byte[] key0, byte[] seconds1, byte[] value2) throws RedisException { _put(key0, value2, bytesToNum(seconds1) * 1000 + now()); return OK; }
/** * Set the value and expiration of a key * String * * @param key0 * @param seconds1 * @param value2 * @return StatusReply */ @Override public StatusReply setex(byte[] key0, byte[] seconds1, byte[] value2) throws RedisException { _put(key0, value2, bytesToNum(seconds1) * 1000 + now()); return OK; }
/** * Set the value and expiration in milliseconds of a key * String * * @param key0 * @param milliseconds1 * @param value2 * @return Reply */ @Override public Reply psetex(byte[] key0, byte[] milliseconds1, byte[] value2) throws RedisException { _put(key0, value2, bytesToNum(milliseconds1) + now()); return OK; }
/** * Set the value and expiration in milliseconds of a key * String * * @param key0 * @param milliseconds1 * @param value2 * @return Reply */ @Override public Reply psetex(byte[] key0, byte[] milliseconds1, byte[] value2) throws RedisException { _put(key0, value2, bytesToNum(milliseconds1) + now()); return OK; }
/** * Set the expiration for a key as a UNIX timestamp specified in milliseconds * Generic * * @param key0 * @param milliseconds_timestamp1 * @return IntegerReply */ @Override public IntegerReply pexpireat(byte[] key0, byte[] milliseconds_timestamp1) throws RedisException { Object o = _get(key0); if (o == null) { return integer(0); } else { expires.put(key0, bytesToNum(milliseconds_timestamp1)); return integer(1); } }
/** * Set a key's time to live in milliseconds * Generic * * @param key0 * @param milliseconds1 * @return IntegerReply */ @Override public IntegerReply pexpire(byte[] key0, byte[] milliseconds1) throws RedisException { Object o = _get(key0); if (o == null) { return integer(0); } else { expires.put(key0, bytesToNum(milliseconds1) + now()); return integer(1); } }
/** * Set a key's time to live in seconds * Generic * * @param key0 * @param seconds1 * @return IntegerReply */ @Override public IntegerReply expire(byte[] key0, byte[] seconds1) throws RedisException { Object o = _get(key0); if (o == null) { return integer(0); } else { expires.put(key0, bytesToNum(seconds1) * 1000 + now()); return integer(1); } }
/** * Set a key's time to live in milliseconds * Generic * * @param key0 * @param milliseconds1 * @return IntegerReply */ @Override public IntegerReply pexpire(byte[] key0, byte[] milliseconds1) throws RedisException { Object o = _get(key0); if (o == null) { return integer(0); } else { expires.put(key0, bytesToNum(milliseconds1) + now()); return integer(1); } }
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(); } }