redis.clients.jedis.params.sortedset.ZAddParams类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(206)

本文整理了Java中redis.clients.jedis.params.sortedset.ZAddParams类的一些代码示例,展示了ZAddParams类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZAddParams类的具体详情如下:
包路径:redis.clients.jedis.params.sortedset.ZAddParams
类名称:ZAddParams

ZAddParams介绍

暂无

代码示例

代码示例来源:origin: sohutv/cachecloud

public byte[][] getByteParams(byte[] key, byte[]... args) {
 ArrayList<byte[]> byteParams = new ArrayList<byte[]>();
 byteParams.add(key);
 if (contains(NX)) {
  byteParams.add(SafeEncoder.encode(NX));
 }
 if (contains(XX)) {
  byteParams.add(SafeEncoder.encode(XX));
 }
 if (contains(CH)) {
  byteParams.add(SafeEncoder.encode(CH));
 }
 for (byte[] arg : args) {
  byteParams.add(arg);
 }
 return byteParams.toArray(new byte[byteParams.size()][]);
}

代码示例来源:origin: Netflix/conductor

public Long zaddnx(String key, double score, String member) {
  ZAddParams params = ZAddParams.zAddParams().nx();
  Long retVal = dynoClient.zadd(key, score, member, params);
  return retVal;
}

代码示例来源:origin: sohutv/cachecloud

public static ZAddParams zAddParams() {
 return new ZAddParams();
}

代码示例来源:origin: dufyun/learn-tech-collection

public Long zupdate(String key, double score, String value) {
  return jedisCluster.zadd(key, score, value,ZAddParams.zAddParams().xx());
}

代码示例来源:origin: Netflix/conductor

@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());
}

代码示例来源:origin: sohutv/cachecloud

/**
 * Modify the return value from the number of new elements added to the total number of elements
 * changed
 * @return ZAddParams
 */
public ZAddParams ch() {
 addParam(CH);
 return this;
}

代码示例来源:origin: Netflix/dyno-queues

@Override
public boolean setTimeout(String messageId, long timeout) {
  return execute("setTimeout", "(a shard in) " + queueName, () -> {
    String json = nonQuorumConn.hget(messageStoreKey, messageId);
    if(json == null) {
      return false;
    }
    Message message = om.readValue(json, Message.class);
    message.setTimeout(timeout);
    for (String shard : allShards) {
      String queueShard = getQueueShardKey(queueName, shard);
      Double score = quorumConn.zscore(queueShard, messageId);
      if(score != null) {
        double priorityd = message.getPriority() / 100;
        double newScore = Long.valueOf(clock.millis() + timeout).doubleValue() + priorityd;
        ZAddParams params = ZAddParams.zAddParams().xx();
        quorumConn.zadd(queueShard, newScore, messageId, params);
        json = om.writeValueAsString(message);
        quorumConn.hset(messageStoreKey, message.getId(), json);
        return true;
      }
    }
    return false;
  });
}

代码示例来源:origin: sohutv/cachecloud

/**
 * Only set the key if it does not already exist.
 * @return ZAddParams
 */
public ZAddParams nx() {
 addParam(NX);
 return this;
}

代码示例来源:origin: com.netflix.conductor/conductor-redis-persistence

public Long zaddnx(String key, double score, String member) {
  ZAddParams params = ZAddParams.zAddParams().nx();
  Long retVal = dynoClient.zadd(key, score, member, params);
  return retVal;
}

代码示例来源:origin: Netflix/conductor

@Override
public Long zadd(String key, double score, String member, ZAddParams params) {
  
  try {
    
    if(params.contains("xx")) {
      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);
  }
}

代码示例来源:origin: sohutv/cachecloud

/**
 * Only set the key if it already exist.
 * @return ZAddParams
 */
public ZAddParams xx() {
 addParam(XX);
 return this;
}

代码示例来源:origin: Netflix/dyno-queues

ZAddParams zParams = ZAddParams.zAddParams().nx();

代码示例来源:origin: Netflix/conductor

@Override
public Long zadd(String key, double score, String member, ZAddParams params) {
  
  try {
    
    if(params.contains("xx")) {
      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);
  }
}

代码示例来源:origin: Netflix/dyno-queues

ZAddParams zParams = ZAddParams.zAddParams().nx();

代码示例来源:origin: com.netflix.conductor/conductor-redis-persistence

@Override
public Long zadd(String key, double score, String member, ZAddParams params) {
  
  try {
    
    if(params.contains("xx")) {
      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);
  }
}

代码示例来源:origin: Netflix/dyno-queues

@Override
public Long zadd(String key, double score, String member, ZAddParams params) {
  
  try {
    
    if(params.contains("xx")) {
      Double existing = redis.zscore(key, member);
      if(existing == null) {
        return 0L;
      }
      redis.zadd(key, new ZsetPair(member, score));
      return 1L;
    }else {
      return redis.zadd(key, new ZsetPair(member, score));
    }
    
  } catch (Exception e) {
    throw new JedisException(e);
  }
}

相关文章