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

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

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

Jedis.renamenx介绍

[英]Rename oldkey into newkey but fails if the destination key newkey already exists.

Time complexity: O(1)
[中]将oldkey重命名为newkey,但如果目标密钥newkey已存在,则重命名失败。
时间复杂度:O(1)

代码示例

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

@Override
 public Long execute(Jedis connection) {
  return connection.renamenx(oldkey, newkey);
 }
}.runBinary(2, oldkey, newkey);

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

@Override
 public Long execute(Jedis connection) {
  return connection.renamenx(oldkey, newkey);
 }
}.run(2, oldkey, newkey);

代码示例来源:origin: caoxinyu/RedisClient

@Override
public void command() {
  jedis.select(db);
  if(overwritten)
    jedis.rename(oldKey, newKey);
  else
    result = jedis.renamenx(oldKey, newKey);
}

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

@Override
public Boolean renameNX(byte[] sourceKey, byte[] targetKey) {
  Assert.notNull(sourceKey, "Source key must not be null!");
  Assert.notNull(targetKey, "Target key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().renamenx(sourceKey, targetKey),
          JedisConverters.longToBoolean()));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().renamenx(sourceKey, targetKey),
          JedisConverters.longToBoolean()));
      return null;
    }
    return JedisConverters.toBoolean(connection.getJedis().renamenx(sourceKey, targetKey));
  } catch (Exception ex) {
    throw connection.convertJedisAccessException(ex);
  }
}

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

@Override
 public Long execute(Jedis connection) {
  return connection.renamenx(oldkey, newkey);
 }
}.run(2, oldkey, newkey);

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

@Override
 public Long execute(Jedis connection) {
  return connection.renamenx(oldkey, newkey);
 }
}.runBinary(2, oldkey, newkey);

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

@Override
public Long renamenx(String oldkey, String newkey) {
  return jedis.renamenx(oldkey, newkey);
}

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

@Override
public Long renamenx(String oldkey, String newkey) {
  return jedis.renamenx(oldkey, newkey);
}

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

private Long renamenx0(Jedis j, String key, String newkey) {
  return j.renamenx(key, newkey);
}

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

public Long renamenx(String oldkey, String newkey) {
  return master.renamenx(oldkey, newkey);
}

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

public Long renamenx(byte[] oldkey, byte[] newkey) {
  return master.renamenx(oldkey, newkey);
}

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

@Override
public Long renamenx(byte[] oldkey, byte[] newkey) {
 String command = "renamenx";
 return instrumented(command, () -> delegated.renamenx(oldkey, newkey));
}

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

@Override
public Long renamenx(String oldkey, String newkey) {
 String command = "renamenx";
 return instrumented(command, () -> delegated.renamenx(oldkey, newkey));
}

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

default Long renamenx(String oldkey, String newkey) {
 return this.run((jedis, serializer) -> jedis.renamenx(oldkey, newkey));
}

代码示例来源:origin: org.nutz/nutz-integration-jedis

/**
 * Rename oldkey into newkey but fails if the destination key newkey already exists.
 * <p>
 * Time complexity: O(1)
 *
 * @param oldkey
 * @param newkey
 * @return Integer reply, specifically: 1 if the key was renamed 0 if the target key already exist
 */
public Long renamenx(byte[] oldkey, byte[] newkey) {
  Jedis jedis = getJedis();
  try {
    return jedis.renamenx(oldkey, newkey);
  } finally {Streams.safeClose(jedis);}
}

代码示例来源:origin: org.nutz/nutz-integration-jedis

/**
 * Rename oldkey into newkey but fails if the destination key newkey already exists.
 * <p>
 * Time complexity: O(1)
 *
 * @param oldkey
 * @param newkey
 * @return Integer reply, specifically: 1 if the key was renamed 0 if the target key already exist
 */
public Long renamenx(String oldkey, String newkey) {
  Jedis jedis = getJedis();
  try {
    return jedis.renamenx(oldkey, newkey);
  } finally {Streams.safeClose(jedis);}
}

代码示例来源:origin: youtongluan/sumk

@Override
public java.lang.Long renamenx(java.lang.String oldkey, java.lang.String newkey) {
  Exception e1 = null;
  for (int i = 0; i < tryCount; i++) {
    Jedis jedis = null;
    try {
      jedis = pool.getResource();
      return jedis.renamenx(oldkey, newkey);
    } catch (Exception e) {
      if (isConnectException(e)) {
        Log.get(LOG_NAME).error(this.hosts + " - redis connection failed,idle=" + pool.getNumIdle()
            + ",active=" + pool.getNumActive(), e);
        e1 = e;
        continue;
      }
      Log.get(LOG_NAME).error("renamenx - redis execute error!" + e.getMessage(), e);
      SumkException.throwException(12342411, e.getMessage(), e);
    } finally {
      close(jedis);
    }
  }
  handleRedisException(e1);
  throw new SumkException(12342423, "未知redis异常");
}

代码示例来源:origin: youtongluan/sumk

@Override
public java.lang.Long renamenx(byte[] oldkey, byte[] newkey) {
  Exception e1 = null;
  for (int i = 0; i < tryCount; i++) {
    Jedis jedis = null;
    try {
      jedis = pool.getResource();
      return jedis.renamenx(oldkey, newkey);
    } catch (Exception e) {
      if (isConnectException(e)) {
        Log.get(LOG_NAME).error(this.hosts + " - redis connection failed,idle=" + pool.getNumIdle()
            + ",active=" + pool.getNumActive(), e);
        e1 = e;
        continue;
      }
      Log.get(LOG_NAME).error("renamenx - redis execute error!" + e.getMessage(), e);
      SumkException.throwException(12342411, e.getMessage(), e);
    } finally {
      close(jedis);
    }
  }
  handleRedisException(e1);
  throw new SumkException(12342423, "未知redis异常");
}

代码示例来源:origin: org.springframework.data/spring-data-redis

@Override
public Boolean renameNX(byte[] sourceKey, byte[] targetKey) {
  Assert.notNull(sourceKey, "Source key must not be null!");
  Assert.notNull(targetKey, "Target key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().renamenx(sourceKey, targetKey),
          JedisConverters.longToBoolean()));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().renamenx(sourceKey, targetKey),
          JedisConverters.longToBoolean()));
      return null;
    }
    return JedisConverters.toBoolean(connection.getJedis().renamenx(sourceKey, targetKey));
  } catch (Exception ex) {
    throw connection.convertJedisAccessException(ex);
  }
}

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

@Override
public Boolean renameNX(byte[] sourceKey, byte[] targetKey) {
  Assert.notNull(sourceKey, "Source key must not be null!");
  Assert.notNull(targetKey, "Target key must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().renamenx(sourceKey, targetKey),
          JedisConverters.longToBoolean()));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().renamenx(sourceKey, targetKey),
          JedisConverters.longToBoolean()));
      return null;
    }
    return JedisConverters.toBoolean(connection.getJedis().renamenx(sourceKey, targetKey));
  } catch (Exception ex) {
    throw connection.convertJedisAccessException(ex);
  }
}

相关文章

微信公众号

最新文章

更多

Jedis类方法