redis.clients.jedis.params.ZAddParams Java Examples

The following examples show how to use redis.clients.jedis.params.ZAddParams. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DynoJedisClient.java    From dyno with Apache License 2.0 6 votes vote down vote up
public Long ehsetnx(final String key, final String field, final String value, final long ttl) {
    final String ehashDataKey = ehashDataKey(key);
    final String ehashMetadataKey = ehashMetadataKey(key);
    final DynoJedisPipeline pipeline = this.pipelined();
    final Response<Long> zResponse = pipeline.zadd(ehashMetadataKey, timeInEpochSeconds(ttl), field,
            ZAddParams.zAddParams().ch());
    final Response<Long> hResponse = pipeline.hsetnx(ehashDataKey, field, value);
    pipeline.sync();

    // If metadata operation failed, remove the data and throw exception
    if (!zResponse.get().equals(hResponse.get())) {
        d_hdel(ehashDataKey, field);
        d_zrem(ehashMetadataKey, field);
        throw new DynoException("Metadata inconsistent with data for expireHash: " + ehashDataKey);
    }
    return hResponse.get();
}
 
Example #2
Source File: DynoJedisClient.java    From dyno with Apache License 2.0 6 votes vote down vote up
@Override
public String ehmset(final String key, final Map<String, Pair<String, Long>> hash) {
    final DynoJedisPipeline pipeline = this.pipelined();
    Map<String, String> fields = new HashMap<>();
    Map<String, Double> metadataFields = new HashMap<>();

    hash.keySet().forEach(f -> {
        fields.put(f, hash.get(f).getLeft());
        metadataFields.put(f, timeInEpochSeconds(hash.get(f).getRight()));
    });

    final Response<Long> zResponse = pipeline.zadd(ehashMetadataKey(key), metadataFields,
            ZAddParams.zAddParams().ch());
    final Response<String> hResponse = pipeline.hmset(ehashDataKey(key), fields);
    pipeline.sync();

    return hResponse.get();
}
 
Example #3
Source File: JedisMock.java    From conductor with Apache License 2.0 6 votes vote down vote up
@Override
public Long zadd(String key, double score, String member, ZAddParams params) {
	
	try {
		
		if(params.getParam("xx") != null) {
			Double existing = redis.zscore(key, member);
			if(existing == null) {
				return 0L;
			}
			return redis.zadd(key, new ZsetPair(member, score));
		}else {
			return redis.zadd(key, new ZsetPair(member, score));
		}
		
	} catch (Exception e) {
		throw new JedisException(e);
	}
}
 
Example #4
Source File: JedisMock.java    From conductor with Apache License 2.0 6 votes vote down vote up
@Override
public Long zadd(String key, double score, String member, ZAddParams params) {
	
	try {
		
		if(params.getParam("xx") != null) {
			Double existing = redis.zscore(key, member);
			if(existing == null) {
				return 0L;
			}
			return redis.zadd(key, new ZsetPair(member, score));
		}else {
			return redis.zadd(key, new ZsetPair(member, score));
		}
		
	} catch (Exception e) {
		throw new JedisException(e);
	}
}
 
Example #5
Source File: DynoJedisClient.java    From dyno with Apache License 2.0 5 votes vote down vote up
public OperationResult<Long> d_zadd(final String key, final double score, final String member,
                                    final ZAddParams params) {

    return connPool.executeWithFailover(new BaseKeyOperation<Long>(key, OpName.ZADD) {

        @Override
        public Long execute(Jedis client, ConnectionContext state) {
            return client.zadd(key, score, member, params);
        }

    });
}
 
Example #6
Source File: DynoJedisClient.java    From dyno with Apache License 2.0 5 votes vote down vote up
@Override
public Long ehset(final String key, final String field, final String value, final long ttl)
        throws UnsupportedOperationException, DynoException {
    final DynoJedisPipeline pipeline = this.pipelined();
    final Response<Long> zResponse = pipeline.zadd(ehashMetadataKey(key), timeInEpochSeconds(ttl), field,
            ZAddParams.zAddParams().ch());
    final Response<Long> hResponse = pipeline.hset(ehashDataKey(key), field, value);
    pipeline.sync();

    return hResponse.get();
}
 
Example #7
Source File: DynoJedisPipeline.java    From dyno with Apache License 2.0 5 votes vote down vote up
@Override
public Response<Long> zadd(String key, Map<String, Double> members, ZAddParams params) {
    return new PipelineOperation<Long>() {

        @Override
        Response<Long> execute(Pipeline jedisPipeline) throws DynoException {
            return jedisPipeline.zadd(key, members, params);
        }

    }.execute(key, OpName.ZADD);
}
 
Example #8
Source File: JedisSentinelTest.java    From conductor with Apache License 2.0 5 votes vote down vote up
@Test
public void testZadd() {
    jedisSentinel.zadd("key", new HashMap<>());
    jedisSentinel.zadd("key", new HashMap<>(), ZAddParams.zAddParams());
    jedisSentinel.zadd("key", 1337, "members");
    jedisSentinel.zadd("key", 1337, "members", ZAddParams.zAddParams());
}
 
Example #9
Source File: JedisClusterlTest.java    From conductor with Apache License 2.0 5 votes vote down vote up
@Test
public void testZadd() {
    jedisCluster.zadd("key", new HashMap<>());
    jedisCluster.zadd("key", new HashMap<>(), ZAddParams.zAddParams());
    jedisCluster.zadd("key", 1337, "members");
    jedisCluster.zadd("key", 1337, "members", ZAddParams.zAddParams());
}
 
Example #10
Source File: TracingJedisWrapper.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long zadd(String key, Map<String, Double> scoreMembers, ZAddParams params) {
  Span span = helper.buildSpan("zadd", key);
  span.setTag("scoreMembers", TracingHelper.toString(scoreMembers));
  span.setTag("params", TracingHelper.toString(params.getByteParams()));
  return helper.decorate(span, () -> wrapped.zadd(key, scoreMembers, params));
}
 
Example #11
Source File: TracingJedisWrapper.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long zadd(byte[] key, double score, byte[] member, ZAddParams params) {
  Span span = helper.buildSpan("zadd", key);
  span.setTag("score", score);
  span.setTag("member", Arrays.toString(member));
  span.setTag("params", TracingHelper.toString(params.getByteParams()));
  return helper.decorate(span, () -> wrapped.zadd(key, score, member, params));
}
 
Example #12
Source File: TracingJedisWrapper.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long zadd(String key, double score, String member, ZAddParams params) {
  Span span = helper.buildSpan("zadd", key);
  span.setTag("score", score);
  span.setTag("member", member);
  span.setTag("params", TracingHelper.toString(params.getByteParams()));
  return helper.decorate(span, () -> wrapped.zadd(key, score, member, params));
}
 
Example #13
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long zadd(byte[] key, Map<byte[], Double> scoreMembers, ZAddParams params) {
  Span span = helper.buildSpan("zadd", key);
  span.setTag("scoreMembers", TracingHelper.toStringMap2(scoreMembers));
  span.setTag("params", TracingHelper.toString(params.getByteParams()));
  return helper.decorate(span, () -> super.zadd(key, scoreMembers, params));
}
 
Example #14
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long zadd(byte[] key, double score, byte[] member, ZAddParams params) {
  Span span = helper.buildSpan("zadd", key);
  span.setTag("score", score);
  span.setTag("member", Arrays.toString(member));
  span.setTag("params", TracingHelper.toString(params.getByteParams()));
  return helper.decorate(span, () -> super.zadd(key, score, member, params));
}
 
Example #15
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long zadd(String key, Map<String, Double> scoreMembers, ZAddParams params) {
  Span span = helper.buildSpan("zadd", key);
  span.setTag("scoreMembers", TracingHelper.toString(scoreMembers));
  span.setTag("params", TracingHelper.toString(params.getByteParams()));
  return helper.decorate(span, () -> super.zadd(key, scoreMembers, params));
}
 
Example #16
Source File: TracingJedisWrapper.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long zadd(byte[] key, Map<byte[], Double> scoreMembers, ZAddParams params) {
  Span span = helper.buildSpan("zadd", key);
  span.setTag("scoreMembers", TracingHelper.toStringMap2(scoreMembers));
  span.setTag("params", TracingHelper.toString(params.getByteParams()));
  return helper.decorate(span, () -> wrapped.zadd(key, scoreMembers, params));
}
 
Example #17
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long zadd(String key, double score, String member, ZAddParams params) {
  Span span = helper.buildSpan("zadd", key);
  span.setTag("score", score);
  span.setTag("member", member);
  span.setTag("params", TracingHelper.toString(params.getByteParams()));
  return helper.decorate(span, () -> super.zadd(key, score, member, params));
}
 
Example #18
Source File: InstrumentedPipeline.java    From kork with Apache License 2.0 4 votes vote down vote up
@Override
public Response<Long> zadd(String key, Map<String, Double> scoreMembers, ZAddParams params) {
  String command = "zadd";
  return instrumented(command, () -> delegated.zadd(key, scoreMembers, params));
}
 
Example #19
Source File: InstrumentedJedis.java    From kork with Apache License 2.0 4 votes vote down vote up
@Override
public Long zadd(byte[] key, Map<byte[], Double> scoreMembers, ZAddParams params) {
  String command = "zadd";
  return instrumented(command, () -> delegated.zadd(key, scoreMembers, params));
}
 
Example #20
Source File: DynoJedisClient.java    From dyno with Apache License 2.0 4 votes vote down vote up
@Override
public Long zadd(byte[] arg0, Map<byte[], Double> arg1, ZAddParams arg2) {
    throw new UnsupportedOperationException("not yet implemented");
}
 
Example #21
Source File: DynoJedisClient.java    From dyno with Apache License 2.0 4 votes vote down vote up
@Override
public Long zadd(byte[] arg0, double arg1, byte[] arg2, ZAddParams arg3) {
    throw new UnsupportedOperationException("not yet implemented");
}
 
Example #22
Source File: DynoJedisClient.java    From dyno with Apache License 2.0 4 votes vote down vote up
@Override
public Long zadd(String arg0, Map<String, Double> arg1, ZAddParams arg2) {
    throw new UnsupportedOperationException("not yet implemented");
}
 
Example #23
Source File: InstrumentedPipeline.java    From kork with Apache License 2.0 4 votes vote down vote up
@Override
public Response<Long> zadd(String key, double score, String member, ZAddParams params) {
  String command = "zadd";
  return instrumented(
      command, payloadSize(member), () -> delegated.zadd(key, score, member, params));
}
 
Example #24
Source File: InstrumentedJedis.java    From kork with Apache License 2.0 4 votes vote down vote up
@Override
public Long zadd(byte[] key, double score, byte[] member, ZAddParams params) {
  String command = "zadd";
  return instrumented(command, () -> delegated.zadd(key, score, member, params));
}
 
Example #25
Source File: InstrumentedPipeline.java    From kork with Apache License 2.0 4 votes vote down vote up
@Override
public Response<Long> zadd(byte[] key, double score, byte[] member, ZAddParams params) {
  String command = "zadd";
  return instrumented(
      command, payloadSize(member), () -> delegated.zadd(key, score, member, params));
}
 
Example #26
Source File: InstrumentedPipeline.java    From kork with Apache License 2.0 4 votes vote down vote up
@Override
public Response<Long> zadd(byte[] key, Map<byte[], Double> scoreMembers, ZAddParams params) {
  String command = "zadd";
  return instrumented(command, () -> delegated.zadd(key, scoreMembers, params));
}
 
Example #27
Source File: InstrumentedJedis.java    From kork with Apache License 2.0 4 votes vote down vote up
@Override
public Long zadd(String key, double score, String member, ZAddParams params) {
  String command = "zadd";
  return instrumented(command, () -> delegated.zadd(key, score, member, params));
}
 
Example #28
Source File: InstrumentedJedis.java    From kork with Apache License 2.0 4 votes vote down vote up
@Override
public Long zadd(String key, Map<String, Double> scoreMembers, ZAddParams params) {
  String command = "zadd";
  return instrumented(command, () -> delegated.zadd(key, scoreMembers, params));
}
 
Example #29
Source File: DynoJedisClient.java    From dyno with Apache License 2.0 4 votes vote down vote up
@Override
public Long zadd(String key, double score, String member, ZAddParams params) {
    return d_zadd(key, score, member, params).getResult();
}
 
Example #30
Source File: DynoJedisPipeline.java    From dyno with Apache License 2.0 4 votes vote down vote up
@Override
public Response<Long> zadd(byte[] key, Map<byte[], Double> scoreMembers, ZAddParams params) {
    throw new UnsupportedOperationException("not yet implemented");
}