private Object _put(byte[] key, Object value) { expires.remove(key); return data.put(key, value); }
@Override public V put(Object o, V value) { return put(makeKey(o), value); }
private Object _put(byte[] key, Object value) { expires.remove(key); return data.put(key, value); }
public V put(byte[] bytes, V value) { return put(new BytesKey(bytes), value); }
@Override public boolean addAll(Collection<? extends ZSetEntry> c) { boolean changed = super.addAll(c); for (ZSetEntry zSetEntry : c) { getMap().put(zSetEntry.getKey(), zSetEntry); } return changed; } }
@Override public boolean add(ZSetEntry zSetEntry) { getMap().put(zSetEntry.getKey(), zSetEntry); return super.add(zSetEntry); }
public boolean add(BytesKey key, double score) { ZSetEntry current = map.get(key); if (current != null) { map.remove(key); int index = Collections.binarySearch(list, current); list.remove(index); } ZSetEntry entry = new ZSetEntry(key, score); map.put(key, entry); int index = find(Collections.binarySearch(list, entry)); list.add(index, entry); return current == null; }
@SuppressWarnings("unchecked") private BytesKeyObjectMap<byte[]> _gethash(byte[] key0, boolean create) throws RedisException { Object o = _get(key0); if (o == null) { o = new BytesKeyObjectMap(); if (create) { data.put(key0, o); } } if (!(o instanceof HashMap)) { throw invalidValue(); } return (BytesKeyObjectMap<byte[]>) o; }
@SuppressWarnings("unchecked") private BytesKeySet _getset(byte[] key0, boolean create) throws RedisException { Object o = _get(key0); if (o == null) { o = new BytesKeySet(); if (create) { data.put(key0, o); } } if (!(o instanceof BytesKeySet)) { throw invalidValue(); } return (BytesKeySet) o; }
@SuppressWarnings("unchecked") private ZSet _getzset(byte[] key0, boolean create) throws RedisException { Object o = _get(key0); if (o == null) { o = new ZSet(); if (create) { data.put(key0, o); } } if (!(o instanceof ZSet)) { throw invalidValue(); } return (ZSet) o; }
@SuppressWarnings("unchecked") private BytesKeyObjectMap<byte[]> _gethash(byte[] key0, boolean create) throws RedisException { Object o = _get(key0); if (o == null) { o = new BytesKeyObjectMap(); if (create) { data.put(key0, o); } } if (!(o instanceof HashMap)) { throw invalidValue(); } return (BytesKeyObjectMap<byte[]>) o; }
@SuppressWarnings("unchecked") private BytesKeySet _getset(byte[] key0, boolean create) throws RedisException { Object o = _get(key0); if (o == null) { o = new BytesKeySet(); if (create) { data.put(key0, o); } } if (!(o instanceof BytesKeySet)) { throw invalidValue(); } return (BytesKeySet) o; }
@SuppressWarnings("unchecked") private ZSet _getzset(byte[] key0, boolean create) throws RedisException { Object o = _get(key0); if (o == null) { o = new ZSet(); if (create) { data.put(key0, o); } } if (!(o instanceof ZSet)) { throw invalidValue(); } return (ZSet) o; }
/** * Set the string value of a hash field * Hash * * @param key0 * @param field1 * @param value2 * @return IntegerReply */ @Override public IntegerReply hset(byte[] key0, byte[] field1, byte[] value2) throws RedisException { BytesKeyObjectMap<byte[]> hash = _gethash(key0, true); Object put = hash.put(field1, value2); return put == null ? integer(1) : integer(0); }
/** * Set the string value of a hash field * Hash * * @param key0 * @param field1 * @param value2 * @return IntegerReply */ @Override public IntegerReply hset(byte[] key0, byte[] field1, byte[] value2) throws RedisException { BytesKeyObjectMap<byte[]> hash = _gethash(key0, true); Object put = hash.put(field1, value2); return put == null ? integer(1) : integer(0); }
/** * Set the expiration for a key as a UNIX timestamp * Generic * * @param key0 * @param timestamp1 * @return IntegerReply */ @Override public IntegerReply expireat(byte[] key0, byte[] timestamp1) throws RedisException { Object o = _get(key0); if (o == null) { return integer(0); } else { expires.put(key0, bytesToNum(timestamp1) * 1000); return integer(1); } }
/** * 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 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); } }