本文整理匯總了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();
}
示例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");
}
示例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());
}
示例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());
}
}
示例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();
}
示例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);
}
示例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());
}
}