@Override public Boolean hSet(byte[] key, byte[] field, byte[] value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(field, "Field must not be null!"); Assert.notNull(value, "Value must not be null!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().hset(key, field, value), JedisConverters.longToBoolean())); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().hset(key, field, value), JedisConverters.longToBoolean())); return null; } return JedisConverters.toBoolean(connection.getJedis().hset(key, field, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
private void hset0(String key, String field, String value) { t.hset(key, field, value); }
public static void doRecurringEnqueue(final Jedis jedis, final String namespace, final String queue, final String jobJson, final long future, final long frequency){ final String queueKey = JesqueUtils.createKey(namespace, QUEUE, queue); final String hashKey = JesqueUtils.createRecurringHashKey(queueKey); if (JedisUtils.canUseAsRecurringQueue(jedis, queueKey, hashKey)) { Transaction transaction = jedis.multi(); transaction.zadd(queueKey, future, jobJson); transaction.hset(hashKey, jobJson, String.valueOf(frequency)); if (transaction.exec() == null) { throw new RuntimeException("cannot add " + jobJson + " to recurring queue " + queue); } } else { throw new IllegalArgumentException(queue + " cannot be used as a recurring queue"); } }
@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 Boolean hSet(byte[] key, byte[] field, byte[] value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(field, "Field must not be null!"); Assert.notNull(value, "Value must not be null!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().hset(key, field, value), JedisConverters.longToBoolean())); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().hset(key, field, value), JedisConverters.longToBoolean())); return null; } return JedisConverters.toBoolean(connection.getJedis().hset(key, field, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Boolean hSet(byte[] key, byte[] field, byte[] value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(field, "Field must not be null!"); Assert.notNull(value, "Value must not be null!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().hset(key, field, value), JedisConverters.longToBoolean())); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().hset(key, field, value), JedisConverters.longToBoolean())); return null; } return JedisConverters.toBoolean(connection.getJedis().hset(key, field, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
public FilterBuilder persistConfig(RedisPool pool, FilterBuilder builder) { return pool.safelyReturn(jedis -> { FilterBuilder newConfig = null; //Retry on concurrent changes while (newConfig == null) { if (!builder.overwriteIfExists() && jedis.exists(builder.name())) { newConfig = this.parseConfigHash(jedis.hgetAll(builder.name()), builder.name(), pool); } else { Map<String, String> hash = this.buildConfigHash(builder); jedis.watch(builder.name()); Transaction t = jedis.multi(); hash.forEach((k, v) -> t.hset(builder.name(), k, v)); if (t.exec() != null) { newConfig = builder; } } } return newConfig; }); }
tr.hdel(queueUrl + "-" + shard + "-" + CQSConstants.REDIS_STATE, CQSConstants.REDIS_STATE); } else { tr.hset(queueUrl + "-" + shard + "-" + CQSConstants.REDIS_STATE, CQSConstants.REDIS_STATE, state.name());
tr.hdel(queueUrl + "-" + shard + "-" + CQSConstants.REDIS_STATE, CQSConstants.REDIS_STATE); } else { tr.hset(queueUrl + "-" + shard + "-" + CQSConstants.REDIS_STATE, CQSConstants.REDIS_STATE, state.name());