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

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

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

Jedis.smove介绍

[英]Move the specified member from the set at srckey to the set at dstkey. This operation is atomic, in every given moment the element will appear to be in the source or destination set for accessing clients.

If the source set does not exist or does not contain the specified element no operation is performed and zero is returned, otherwise the element is removed from the source set and added to the destination set. On success one is returned, even if the element was already present in the destination set.

An error is raised if the source or destination keys contain a non Set value.

Time complexity O(1)
[中]将指定的成员从set at srckey移动到set at dstkey。此操作是原子操作,在每个给定时刻,元素都会出现在用于访问客户端的源或目标集中。
如果源集不存在或不包含指定的元素,则不执行任何操作并返回零,否则将从源集中删除该元素并将其添加到目标集。成功时,返回一个元素,即使该元素已存在于目标集中。
如果源键或目标键包含未设置的值,则会引发错误。
时间复杂度O(1)

代码示例

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

@Override
 public Long execute(Jedis connection) {
  return connection.smove(srckey, dstkey, member);
 }
}.run(2, srckey, dstkey);

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

@Override
 public Long execute(Jedis connection) {
  return connection.smove(srckey, dstkey, member);
 }
}.runBinary(2, srckey, dstkey);

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

@Override
public Boolean sMove(byte[] srcKey, byte[] destKey, byte[] value) {
  Assert.notNull(srcKey, "Source key must not be null!");
  Assert.notNull(destKey, "Destination key must not be null!");
  Assert.notNull(value, "Value must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().smove(srcKey, destKey, value),
          JedisConverters.longToBoolean()));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().smove(srcKey, destKey, value),
          JedisConverters.longToBoolean()));
      return null;
    }
    return JedisConverters.toBoolean(connection.getJedis().smove(srcKey, destKey, value));
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

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

@Override
 public Long execute(Jedis connection) {
  return connection.smove(srckey, dstkey, member);
 }
}.run(2, srckey, dstkey);

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

@Override
public Long smove(String srckey, String dstkey, String member) {
  return jedis.smove(srckey, dstkey, member);
}

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

@Override
public Long smove(String srckey, String dstkey, String member) {
  return jedis.smove(srckey, dstkey, member);
}

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

private Long smove0(Jedis j, String source, String destination, String member) {
  return j.smove(source, destination, member);
}

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

@Override
 public Long execute(Jedis connection) {
  return connection.smove(srckey, dstkey, member);
 }
}.runBinary(2, srckey, dstkey);

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

public Long smove(String srckey, String dstkey, String member) {
  return master.smove(srckey, dstkey, member);
}

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

public Long smove(byte[] srckey, byte[] dstkey, byte[] member) {
  return master.smove(srckey, dstkey, member);
}

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

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

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

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

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

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

代码示例来源:origin: chenjunwen/SpringBootFrame

/**
 * <p>通过key将set中的value移除并添加到第二个set中</p>
 *
 * @param srckey 需要移除的
 * @param dstkey 添加的
 * @param member set中的value
 * @return
 */
public Long smove(String srckey, String dstkey, String member) {
  Jedis jedis = null;
  Long res = null;
  try {
    jedis = pool.getResource();
    res = jedis.smove(srckey, dstkey, member);
  } catch (Exception e) {
    LOGGER.error(e.getMessage());
  } finally {
    returnResource(pool, jedis);
  }
  return res;
}

代码示例来源:origin: appleappleapple/DistributeLearning

/**
 * <p>
 * ͨkeysetеvalueƳӵڶset
 * </p>
 * 
 * @param srckey
 *            ҪƳ
 * @param dstkey
 *            ӵ
 * @param member
 *            setеvalue
 * @return
 */
public Long smove(String srckey, String dstkey, String member) {
  Jedis jedis = null;
  Long res = null;
  try {
    jedis = pool.getResource();
    res = jedis.smove(srckey, dstkey, member);
  } catch (Exception e) {
    LOGGER.error(e.getMessage());
  } finally {
    returnResource(pool, jedis);
  }
  return res;
}

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

default Long smove(String srckey, String dstkey, Object member) {
 return this.run((jedis, serializer) -> jedis.smove(SafeEncoder.encode(srckey), SafeEncoder.encode(dstkey), serializer.serialize(member)));
}

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

@Override
public java.lang.Long smove(java.lang.String srckey, java.lang.String dstkey, java.lang.String member) {
  Exception e1 = null;
  for (int i = 0; i < tryCount; i++) {
    Jedis jedis = null;
    try {
      jedis = pool.getResource();
      return jedis.smove(srckey, dstkey, member);
    } 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("smove - 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 smove(byte[] srckey, byte[] dstkey, byte[] member) {
  Exception e1 = null;
  for (int i = 0; i < tryCount; i++) {
    Jedis jedis = null;
    try {
      jedis = pool.getResource();
      return jedis.smove(srckey, dstkey, member);
    } 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("smove - 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 sMove(byte[] srcKey, byte[] destKey, byte[] value) {
  Assert.notNull(srcKey, "Source key must not be null!");
  Assert.notNull(destKey, "Destination key must not be null!");
  Assert.notNull(value, "Value must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().smove(srcKey, destKey, value),
          JedisConverters.longToBoolean()));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().smove(srcKey, destKey, value),
          JedisConverters.longToBoolean()));
      return null;
    }
    return JedisConverters.toBoolean(connection.getJedis().smove(srcKey, destKey, value));
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

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

@Override
public Boolean sMove(byte[] srcKey, byte[] destKey, byte[] value) {
  Assert.notNull(srcKey, "Source key must not be null!");
  Assert.notNull(destKey, "Destination key must not be null!");
  Assert.notNull(value, "Value must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().smove(srcKey, destKey, value),
          JedisConverters.longToBoolean()));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().smove(srcKey, destKey, value),
          JedisConverters.longToBoolean()));
      return null;
    }
    return JedisConverters.toBoolean(connection.getJedis().smove(srcKey, destKey, value));
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

相关文章

Jedis类方法