redis.clients.jedis.Jedis.rpoplpush()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(152)

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

Jedis.rpoplpush介绍

[英]Atomically return and remove the last (tail) element of the srckey list, and push the element as the first (head) element of the dstkey list. For example if the source list contains the elements "a","b","c" and the destination list contains the elements "foo","bar" after an RPOPLPUSH command the content of the two lists will be "a","b" and "c","foo","bar".

If the key does not exist or the list is already empty the special value 'nil' is returned. If the srckey and dstkey are the same the operation is equivalent to removing the last element from the list and pushing it as first element of the list, so it's a "list rotation" command.

Time complexity: O(1)
[中]以原子方式返回并删除srckey列表的最后一个(tail)元素,并将该元素作为dstkey列表的第一个(head)元素推送。例如,如果源列表包含元素“a”、“b”、“c”,而目标列表包含RPOPLPUSH命令后的元素“foo”、“bar”,则两个列表的内容将是“a”、“b”和“c”、“foo”、“bar”。
如果键不存在或列表已为空,则返回特殊值“nil”。如果srckey和dstkey相同,则该操作相当于从列表中删除最后一个元素并将其作为列表的第一个元素推送,因此它是一个“列表旋转”命令。
时间复杂度:O(1)

代码示例

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

@Override
 public byte[] execute(Jedis connection) {
  return connection.rpoplpush(srckey, dstkey);
 }
}.runBinary(2, srckey, dstkey);

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

@Override
 public String execute(Jedis connection) {
  return connection.rpoplpush(srckey, dstkey);
 }
}.run(2, srckey, dstkey);

代码示例来源:origin: jfinal/jfinal

/**
 * 命令 RPOPLPUSH 在一个原子时间内,执行以下两个动作:
 * 将列表 source 中的最后一个元素(尾元素)弹出,并返回给客户端。
 * 将 source 弹出的元素插入到列表 destination ,作为 destination 列表的的头元素。
 */
@SuppressWarnings("unchecked")
public <T> T rpoplpush(Object srcKey, Object dstKey) {
  Jedis jedis = getJedis();
  try {
    return (T)valueFromBytes(jedis.rpoplpush(keyToBytes(srcKey), keyToBytes(dstKey)));
  }
  finally {close(jedis);}
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public byte[] rPopLPush(byte[] srcKey, byte[] dstKey) {
  Assert.notNull(srcKey, "Source key must not be null!");
  Assert.notNull(dstKey, "Destination key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().rpoplpush(srcKey, dstKey)));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().rpoplpush(srcKey, dstKey)));
      return null;
    }
    return connection.getJedis().rpoplpush(srcKey, dstKey);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: apache/servicemix-bundles

@Override
 public byte[] execute(Jedis connection) {
  return connection.rpoplpush(srckey, dstkey);
 }
}.runBinary(2, srckey, dstkey);

代码示例来源:origin: apache/servicemix-bundles

@Override
 public String execute(Jedis connection) {
  return connection.rpoplpush(srckey, dstkey);
 }
}.run(2, srckey, dstkey);

代码示例来源:origin: yrain/smart-cache

@Override
  byte[] doInJedis(Jedis jedis) {
    return jedis.rpoplpush(srcKey, dstKey);
  }
});

代码示例来源:origin: tangyanbo/springmore

@Override
  public String action(Jedis jedis) {
    return jedis.rpoplpush(sourceKey, destinationKey);
  }
});

代码示例来源:origin: io.leopard/leopard-redis

@Override
public String rpoplpush(String srckey, String dstkey) {
  return jedis.rpoplpush(srckey, dstkey);
}

代码示例来源:origin: io.leopard/leopard-redis

@Override
public String rpoplpush(String srckey, String dstkey) {
  return jedis.rpoplpush(srckey, dstkey);
}

代码示例来源:origin: penggle/jedis-ms-sentinel

public byte[] rpoplpush(byte[] srckey, byte[] dstkey) {
  return master.rpoplpush(srckey, dstkey);
}

代码示例来源:origin: mindwind/craft-atom

private String rpoplpush0(Jedis j, String source, String destination) {
  return j.rpoplpush(source, destination);
}

代码示例来源:origin: penggle/jedis-ms-sentinel

public String rpoplpush(String srckey, String dstkey) {
  return master.rpoplpush(srckey, dstkey);
}

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public byte[] rpoplpush(byte[] srckey, byte[] dstkey) {
 String command = "rpoplpush";
 return instrumented(command, () -> delegated.rpoplpush(srckey, dstkey));
}

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public String rpoplpush(String srckey, String dstkey) {
 String command = "rpoplpush";
 return instrumented(command, () -> delegated.rpoplpush(srckey, dstkey));
}

代码示例来源:origin: wxiaoqi/ace-cache

@Override
public String rpoplpush(String srckey, String dstkey) {
  Jedis jedis = null;
  String res = null;
  try {
    jedis = pool.getResource();
    res = jedis.rpoplpush(srckey, dstkey);
  } catch (Exception e) {
    LOGGER.error(e.getMessage());
  } finally {
    returnResource(pool, jedis);
  }
  return res;
}

代码示例来源:origin: io.enoa/nosql-redis

default <T> T rpoplpush(String srckey, String dstkey) {
 return this.run((jedis, serializer) -> serializer.<T>reduction(jedis.rpoplpush(SafeEncoder.encode(srckey), SafeEncoder.encode(dstkey))));
}

代码示例来源:origin: com.jfinal/jfinal

/**
 * 命令 RPOPLPUSH 在一个原子时间内,执行以下两个动作:
 * 将列表 source 中的最后一个元素(尾元素)弹出,并返回给客户端。
 * 将 source 弹出的元素插入到列表 destination ,作为 destination 列表的的头元素。
 */
@SuppressWarnings("unchecked")
public <T> T rpoplpush(Object srcKey, Object dstKey) {
  Jedis jedis = getJedis();
  try {
    return (T)valueFromBytes(jedis.rpoplpush(keyToBytes(srcKey), keyToBytes(dstKey)));
  }
  finally {close(jedis);}
}

代码示例来源:origin: yangfuhai/jboot

/**
 * 命令 RPOPLPUSH 在一个原子时间内,执行以下两个动作:
 * 将列表 source 中的最后一个元素(尾元素)弹出,并返回给客户端。
 * 将 source 弹出的元素插入到列表 destination ,作为 destination 列表的的头元素。
 */
@SuppressWarnings("unchecked")
public <T> T rpoplpush(Object srcKey, Object dstKey) {
  Jedis jedis = getJedis();
  try {
    return (T) valueFromBytes(jedis.rpoplpush(keyToBytes(srcKey), keyToBytes(dstKey)));
  } finally {
    returnResource(jedis);
  }
}

代码示例来源:origin: com.github.sogyf/goja-jfinal

/**
 * 命令 RPOPLPUSH 在一个原子时间内,执行以下两个动作:
 * 将列表 source 中的最后一个元素(尾元素)弹出,并返回给客户端。
 * 将 source 弹出的元素插入到列表 destination ,作为 destination 列表的的头元素。
 */
@SuppressWarnings("unchecked")
public <T> T rpoplpush(Object srcKey, Object dstKey) {
  Jedis jedis = getJedis();
  try {
    return (T)valueFromBytes(jedis.rpoplpush(keyToBytes(srcKey), keyToBytes(dstKey)));
  }
  finally {close(jedis);}
}

相关文章

微信公众号

最新文章

更多

Jedis类方法