本文整理汇总了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());
}
}