@Override public Long sAdd(byte[] key, byte[]... values) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(values, "Values must not be null!"); Assert.noNullElements(values, "Values must not contain null elements!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().sadd(key, values))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().sadd(key, values))); return null; } return connection.getJedis().sadd(key, values); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
private void sadd0(String key, String... members) { t.sadd(key, members); }
@Override public void set(String key, String sessionsKey, byte[] session, int timeout) throws UnsupportedEncodingException { try(Jedis jedis = this.jedisPool.getResource()) { Transaction t = jedis.multi(); t.setex(key.getBytes(Protocol.CHARSET), timeout, session); t.sadd(sessionsKey, key); t.exec(); } }
@Test public void set() throws UnsupportedEncodingException { byte[] session = "session".getBytes(); this.jedisNodeClient.set("key", SESSIONS_KEY, session, timeout); verify(this.transaction, times(1)).setex("key".getBytes(Protocol.CHARSET), timeout, session); verify(this.transaction, times(1)).sadd(SESSIONS_KEY,"key"); verify(this.transaction, times(1)).exec(); verify(this.jedis, times(1)).close(); }
@Override public Long sAdd(byte[] key, byte[]... values) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(values, "Values must not be null!"); Assert.noNullElements(values, "Values must not contain null elements!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().sadd(key, values))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().sadd(key, values))); return null; } return connection.getJedis().sadd(key, values); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public void register(final Node node) { try (final Jedis jedis = redisConnector.getResource()) { final Boolean isIdUsed = jedis.sismember(VERTIGO_NODES, node.getId()); Assertion.checkState(!isIdUsed, "A node id must be unique : Id '{0}' is already used ", node.getId()); // --- try (final Transaction tx = jedis.multi()) { tx.hset(VERTIGO_NODE + node.getId(), "json", gson.toJson(node)); tx.sadd(VERTIGO_NODES, node.getId()); tx.exec(); } catch (final IOException e) { throw WrappedException.wrap(e); } } }
@Override public Long sAdd(byte[] key, byte[]... values) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(values, "Values must not be null!"); Assert.noNullElements(values, "Values must not contain null elements!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().sadd(key, values))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().sadd(key, values))); return null; } return connection.getJedis().sadd(key, values); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
transaction.expireAt(attributeKey.getBytes(RedisSessionKeys.getEncoding()), getUnixTime(currentExpireAtTimeWithReserve)); transaction.sadd(attrsListKey, name); transaction.expireAt(attrsListKey, getUnixTime(currentExpireAtTimeWithReserve));
transaction.expireAt(attributeKey.getBytes(RedisSessionKeys.getEncoding()), getUnixTime(currentExpireAtTimeWithReserve)); transaction.sadd(attrsListKey, name); transaction.expireAt(attrsListKey, getUnixTime(currentExpireAtTimeWithReserve));
@Override public boolean saveChannel(final Channel channel) { final Jedis jedis = jedisPool.getResource(); try { final String uaid = channel.getUAID(); final String chid = channel.getChannelId(); if (jedis.sismember(uaidLookupKey(uaid), chid)) { return false; } final String endpointToken = channel.getEndpointToken(); final Transaction tx = jedis.multi(); tx.set(endpointToken, Long.toString(channel.getVersion())); tx.set(tokenLookupKey(endpointToken), chid); tx.hmset(chidLookupKey(chid), mapOf(endpointToken, uaid)); tx.sadd(uaidLookupKey(uaid), chid); tx.exec(); return true; } finally { jedisPool.returnResource(jedis); } }