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

x33g5p2x  于2022-01-30 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(224)

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

Transaction.sadd介绍

暂无

代码示例

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

@Override
public Long sAdd(byte[] key, byte[]... values) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(values, "Values must not be null!");
  Assert.noNullElements(values, "Values must not contain null elements!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().sadd(key, values)));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().sadd(key, values)));
      return null;
    }
    return connection.getJedis().sadd(key, values);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

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

private void sadd0(String key, String... members) {
  t.sadd(key, members);
}

代码示例来源:origin: pivotalsoftware/session-managers

@Override
public void set(String key, String sessionsKey, byte[] session, int timeout) throws UnsupportedEncodingException {
  try(Jedis jedis = this.jedisPool.getResource()) {
    Transaction t = jedis.multi();
    t.setex(key.getBytes(Protocol.CHARSET), timeout, session);
    t.sadd(sessionsKey, key);
    t.exec();
  }
}

代码示例来源:origin: pivotalsoftware/session-managers

@Test
public void set() throws UnsupportedEncodingException {
  byte[] session = "session".getBytes();
  this.jedisNodeClient.set("key", SESSIONS_KEY, session, timeout);
  verify(this.transaction, times(1)).setex("key".getBytes(Protocol.CHARSET), timeout, session);
  verify(this.transaction, times(1)).sadd(SESSIONS_KEY,"key");
  verify(this.transaction, times(1)).exec();
  verify(this.jedis, times(1)).close();
}

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

@Override
public Long sAdd(byte[] key, byte[]... values) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(values, "Values must not be null!");
  Assert.noNullElements(values, "Values must not contain null elements!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().sadd(key, values)));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().sadd(key, values)));
      return null;
    }
    return connection.getJedis().sadd(key, values);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: KleeGroup/vertigo

@Override
public void register(final Node node) {
  try (final Jedis jedis = redisConnector.getResource()) {
    final Boolean isIdUsed = jedis.sismember(VERTIGO_NODES, node.getId());
    Assertion.checkState(!isIdUsed, "A node id must be unique : Id '{0}' is already used ", node.getId());
    // ---
    try (final Transaction tx = jedis.multi()) {
      tx.hset(VERTIGO_NODE + node.getId(), "json", gson.toJson(node));
      tx.sadd(VERTIGO_NODES, node.getId());
      tx.exec();
    } catch (final IOException e) {
      throw WrappedException.wrap(e);
    }
  }
}

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

@Override
public Long sAdd(byte[] key, byte[]... values) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(values, "Values must not be null!");
  Assert.noNullElements(values, "Values must not contain null elements!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().sadd(key, values)));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().sadd(key, values)));
      return null;
    }
    return connection.getJedis().sadd(key, values);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: com.github.jkutner/tomcat-redis-session

transaction.expireAt(attributeKey.getBytes(RedisSessionKeys.getEncoding()), getUnixTime(currentExpireAtTimeWithReserve));
transaction.sadd(attrsListKey, name);
transaction.expireAt(attrsListKey, getUnixTime(currentExpireAtTimeWithReserve));

代码示例来源:origin: zinin/tomcat-redis-session

transaction.expireAt(attributeKey.getBytes(RedisSessionKeys.getEncoding()), getUnixTime(currentExpireAtTimeWithReserve));
transaction.sadd(attrsListKey, name);
transaction.expireAt(attrsListKey, getUnixTime(currentExpireAtTimeWithReserve));

代码示例来源:origin: aerogear/aerogear-simplepush-server

@Override
public boolean saveChannel(final Channel channel) {
  final Jedis jedis = jedisPool.getResource();
  try {
    final String uaid = channel.getUAID();
    final String chid = channel.getChannelId();
    if (jedis.sismember(uaidLookupKey(uaid), chid)) {
      return false;
    }
    final String endpointToken = channel.getEndpointToken();
    final Transaction tx = jedis.multi();
    tx.set(endpointToken, Long.toString(channel.getVersion()));
    tx.set(tokenLookupKey(endpointToken), chid);
    tx.hmset(chidLookupKey(chid), mapOf(endpointToken, uaid));
    tx.sadd(uaidLookupKey(uaid), chid);
    tx.exec();
    return true;
  } finally {
    jedisPool.returnResource(jedis);
  }
}

相关文章

微信公众号

最新文章

更多

Transaction类方法