當前位置: 首頁>>代碼示例>>Java>>正文


Java Transaction.sadd方法代碼示例

本文整理匯總了Java中redis.clients.jedis.Transaction.sadd方法的典型用法代碼示例。如果您正苦於以下問題:Java Transaction.sadd方法的具體用法?Java Transaction.sadd怎麽用?Java Transaction.sadd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在redis.clients.jedis.Transaction的用法示例。


在下文中一共展示了Transaction.sadd方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testExec

import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@Test
public void testExec() throws Exception {
  int rnd = ThreadLocalRandom.current().nextInt(0, presetElements.size());
  String key = presetElementKeys.get(rnd);
  String value = String.valueOf(presetElements.get(key));

  Transaction transaction = jedis.multi();

  Snapshot snapshot = commandTracker.snapshot();
  Snapshot discardSnapshot = discardTracker.snapshot();
  Snapshot txsnapshot = execTracker.snapshot();
  txsnapshot.increment();
  Response<Long> added = transaction.sadd(key, value);
  transaction.exec();
  assertEquals(1, (long) added.get());
  txsnapshot.validate();
  snapshot.validate();
  discardSnapshot.validate();
}
 
開發者ID:ApptuitAI,項目名稱:JInsight,代碼行數:20,代碼來源:JedisTransactionInstrumentationTest.java

示例2: testDiscard

import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@Test
public void testDiscard() throws Exception {
  int rnd = ThreadLocalRandom.current().nextInt(0, presetElements.size());
  String key = presetElementKeys.get(rnd);
  String value = String.valueOf(presetElements.get(key));

  Transaction transaction = jedis.multi();

  Snapshot snapshot = commandTracker.snapshot();
  Snapshot discardSnapshot = discardTracker.snapshot();
  Snapshot txsnapshot = execTracker.snapshot();
  discardSnapshot.increment();
  Response<Long> added = transaction.sadd(key, value);
  transaction.discard();
  assertNull(jedis.get(key));
  txsnapshot.validate();
  snapshot.validate();
  discardSnapshot.validate();
}
 
開發者ID:ApptuitAI,項目名稱:JInsight,代碼行數:20,代碼來源:JedisTransactionInstrumentationTest.java

示例3: testCloseDiscards

import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@Test
public void testCloseDiscards() throws Exception {
  int rnd = ThreadLocalRandom.current().nextInt(0, presetElements.size());
  String key = presetElementKeys.get(rnd);
  String value = String.valueOf(presetElements.get(key));

  Transaction transaction = jedis.multi();

  Snapshot snapshot = commandTracker.snapshot();
  Snapshot discardSnapshot = discardTracker.snapshot();
  Snapshot txsnapshot = execTracker.snapshot();
  discardSnapshot.increment();
  Response<Long> added = transaction.sadd(key, value);
  transaction.close();
  assertNull(jedis.get(key));
  txsnapshot.validate();
  snapshot.validate();
  discardSnapshot.validate();
}
 
開發者ID:ApptuitAI,項目名稱:JInsight,代碼行數:20,代碼來源:JedisTransactionInstrumentationTest.java

示例4: doCallback

import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@Override
public void doCallback(Transaction tx) {
	for (Command cmd : redisCommands) {
		switch (cmd.getOp()) {
			case SET:
				tx.set(cmd.getCacheKey(), cmd.getCacheValue());
				break;
			case MOD:
				tx.set(cmd.getCacheKey(), cmd.getCacheValue());
				break;
			case DEL:
				tx.del(cmd.getCacheKey());
				break;
			case ADD_MEMBERS:
				tx.sadd(cmd.getCacheGroupKey(), cmd.getGroupValues());
				break;
			case DEL_MEMBERS:
				tx.srem(cmd.getCacheGroupKey(), cmd.getGroupValues());
				break;
			case SETS:
				tx.mset(cmd.getKeyvalues());
			default:
				break;
		}
	}
}
 
開發者ID:leopardoooo,項目名稱:easyooo-framework,代碼行數:27,代碼來源:DefaultRedisTransactionCallback.java

示例5: multi

import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@Test
public void multi() {
  Transaction trans = jedis.multi();

  trans.sadd("foo", "a");
  trans.sadd("foo", "b");
  trans.scard("foo");

  List<Object> response = trans.exec();

  List<Object> expected = new ArrayList<Object>();
  expected.add(1L);
  expected.add(1L);
  expected.add(2L);
  assertEquals(expected, response);

  // Binary
  trans = jedis.multi();

  trans.sadd(bfoo, ba);
  trans.sadd(bfoo, bb);
  trans.scard(bfoo);

  response = trans.exec();

  expected = new ArrayList<Object>();
  expected.add(1L);
  expected.add(1L);
  expected.add(2L);
  assertEquals(expected, response);

}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:33,代碼來源:TransactionCommandsTest.java

示例6: set

import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@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();
    }
}
 
開發者ID:pivotalsoftware,項目名稱:session-managers,代碼行數:10,代碼來源:JedisNodeClient.java


注:本文中的redis.clients.jedis.Transaction.sadd方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。