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


Java Transaction.get方法代碼示例

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


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

示例1: testResetStateWithFullyExecutedTransaction

import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@Test
public void testResetStateWithFullyExecutedTransaction() {
  Jedis jedis2 = new Jedis(jedis.getClient().getHost(), jedis.getClient().getPort());
  jedis2.auth("foobared");

  Transaction t = jedis2.multi();
  t.set("mykey", "foo");
  t.get("mykey");

  List<Object> resp = t.exec();
  assertNotNull(resp);
  assertEquals(2, resp.size());

  jedis2.resetState();
  jedis2.close();
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:17,代碼來源:TransactionCommandsTest.java

示例2: transactionResponseWithError

import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@Test
public void transactionResponseWithError() {
  Transaction t = jedis.multi();
  t.set("foo", "bar");
  Response<Set<String>> error = t.smembers("foo");
  Response<String> r = t.get("foo");
  List<Object> l = t.exec();
  assertEquals(JedisDataException.class, l.get(1).getClass());
  try {
    error.get();
    fail("We expect exception here!");
  } catch (JedisDataException e) {
    // that is fine we should be here
  }
  assertEquals(r.get(), "bar");
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:17,代碼來源:TransactionCommandsTest.java

示例3: execGetResponse

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

  t.set("foo", "bar");
  t.smembers("foo");
  t.get("foo");

  List<Response<?>> lr = t.execGetResponse();
  try {
    lr.get(1).get();
    fail("We expect exception here!");
  } catch (JedisDataException e) {
    // that is fine we should be here
  }
  assertEquals("bar", lr.get(2).get());
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:18,代碼來源:TransactionCommandsTest.java

示例4: remove

import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@Override
public <E extends EntityType, T extends TokenType> AuthenticationToken<E, T> remove(final TokenProxy<E, T> tokenProxy) throws IOException {
    try(final Jedis jedis = jedisPool.getResource()) {
        final byte[] keyBytes = serialize(tokenProxy);

        final Transaction transaction = jedis.multi();

        final Response<byte[]> oldTokenResponse = transaction.get(keyBytes);
        transaction.del(keyBytes);

        transaction.exec();

        //noinspection unchecked
        return (AuthenticationToken<E, T>) deserialize(oldTokenResponse.get());
    }
}
 
開發者ID:hpe-idol,項目名稱:redis-hod-token-repository,代碼行數:17,代碼來源:RedisTokenRepository.java

示例5: transactionResponseWithinPipeline

import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@Test(expected = JedisDataException.class)
public void transactionResponseWithinPipeline() {
  jedis.set("string", "foo");

  Transaction t = jedis.multi();
  Response<String> string = t.get("string");
  string.get();
  t.exec();
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:10,代碼來源:TransactionCommandsTest.java

示例6: getSet

import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
public String getSet(String chave, String novoValor) {
	Jedis jedis = new Jedis("localhost");
	Transaction transaction = jedis.multi();

	transaction.get(chave);
	transaction.set(chave, novoValor);

	List<Object> resultados = transaction.exec();

	return (String) resultados.get(0);
}
 
開發者ID:rlazoti,項目名稱:exemplos-livro-redis,代碼行數:12,代碼來源:ExecutarGetSetEmTransacao.java

示例7: update

import redis.clients.jedis.Transaction; //導入方法依賴的package包/類
@Override
public <E extends EntityType, T extends TokenType> AuthenticationToken<E, T> update(final TokenProxy<E, T> tokenProxy, final AuthenticationToken<E, T> authenticationToken) throws IOException {
    checkTokenExpiry(authenticationToken);

    try(final Jedis jedis = jedisPool.getResource()) {
        final byte[] keyBytes = serialize(tokenProxy);

        final Transaction transaction = jedis.multi();

        final Response<byte[]> oldTokenResponse = transaction.get(keyBytes);

        transaction.set(keyBytes, serialize(authenticationToken), "XX".getBytes(), "EX".getBytes(), getExpirySeconds(authenticationToken.getExpiry()));

        transaction.exec();

        //noinspection unchecked
        return (AuthenticationToken<E, T>) deserialize(oldTokenResponse.get());
    }
}
 
開發者ID:hpe-idol,項目名稱:redis-hod-token-repository,代碼行數:20,代碼來源:RedisTokenRepository.java


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