Search in sources :

Example 41 with Transaction

use of redis.clients.jedis.Transaction in project leopard by tanhaichao.

the class RedisImpl method append.

@Override
public boolean append(final String key, final String value, final int seconds) {
    return (Boolean) this.execute(new Invoker() {

        @Override
        public Object execute(Jedis jedis) {
            Transaction transaction = jedis.multi();
            transaction.append(key, value);
            transaction.expire(key, seconds);
            transaction.exec();
            return true;
        }
    });
}
Also used : Jedis(redis.clients.jedis.Jedis) Transaction(redis.clients.jedis.Transaction)

Example 42 with Transaction

use of redis.clients.jedis.Transaction in project leopard by tanhaichao.

the class RedisImpl method set.

@Override
public boolean set(final List<String> keyList, final List<String> valueList) {
    RedisUtil.checkList(keyList, valueList);
    return (Boolean) this.execute(new Invoker() {

        @Override
        public Object execute(Jedis jedis) {
            Transaction transaction = jedis.multi();
            for (int i = 0; i < keyList.size(); i++) {
                transaction.set(keyList.get(i), valueList.get(i));
            }
            transaction.exec();
            return true;
        }
    });
}
Also used : Jedis(redis.clients.jedis.Jedis) Transaction(redis.clients.jedis.Transaction)

Aggregations

Transaction (redis.clients.jedis.Transaction)42 Test (org.junit.Test)32 Jedis (redis.clients.jedis.Jedis)19 Set (java.util.Set)7 JedisDataException (redis.clients.jedis.exceptions.JedisDataException)6 GenericObjectPoolConfig (org.apache.commons.pool2.impl.GenericObjectPoolConfig)4 JedisException (redis.clients.jedis.exceptions.JedisException)4 Response (redis.clients.jedis.Response)3 ArrayList (java.util.ArrayList)2 JedisPool (redis.clients.jedis.JedisPool)2 JedisSentinelPool (redis.clients.jedis.JedisSentinelPool)2 JedisConnectionException (redis.clients.jedis.exceptions.JedisConnectionException)2 TicketModel (com.gitblit.models.TicketModel)1 Change (com.gitblit.models.TicketModel.Change)1 ResourceMetadata (org.opennms.newts.cassandra.search.ResourceMetadata)1