Package redis.clients.jedis

Examples of redis.clients.jedis.Pipeline$MultiResponseBuilder


        try {
            final Jedis shard = jedis.getShard(idx.key());
            shard.del(idx.cat(Seek.INFO).cat(Seek.TOTAL).key());
            final Map<String, String> facets = shard.hgetAll(idx.cat(Seek.INFO)
                    .key());
            Pipeline p = shard.pipelined();
            for (String facetField : facets.keySet()) {
                p.del(idx.cat(Seek.INFO).cat(facetField).key());
            }
            p.del(idx.cat(Seek.INFO).key());
            p.execute();
            getPool().returnResource(jedis);
        } catch (Exception e) {
            pool.returnResource(jedis);
            throw new SeekException(e);
        }
View Full Code Here


        Nest ndx = idx.fork();
        idx = ndx.cat(id).fork();
        ShardedJedis jedis = Seek.getPool().getResource();
        Jedis shard = jedis.getShard(ndx.key());
        try {
            Pipeline p = shard.pipelined();
            // List<String> indexes =
            p.lrange(idx.key(), 0, -1);
            // Map<String, String> fields =
            p.hgetAll(idx.cat(Seek.FIELDS).key());
            // List<String> tags =
            p.lrange(idx.cat(Seek.TAGS).key(), 0, -1);
            List<Object> data = p.execute();
            List<byte[]> indexes = (List<byte[]>) data.get(0);
            List<byte[]> fields = (List<byte[]>) data.get(1);
            List<byte[]> tags = (List<byte[]>) data.get(2);

            p = shard.pipelined();
            p.decr(ndx.cat(Seek.INFO).cat(Seek.TOTAL).key());
            for (byte[] index : indexes) {
                p.zrem(SafeEncoder.encode(index), id);
            }
            p.del(idx.key());
            for (byte[] tag : tags) {
                p.hincrBy(ndx.cat(Seek.INFO).cat(Seek.TAGS).key(), SafeEncoder
                        .encode(tag), -1);
            }
            Iterator<byte[]> iterator = fields.iterator();
            while (iterator.hasNext()) {
                String field = SafeEncoder.encode(iterator.next());
                String key = SafeEncoder.encode(iterator.next());
                p.hincrBy(ndx.cat(Seek.INFO).key(), field, -1);
                p.hincrBy(ndx.cat(Seek.INFO).cat(field).key(), key, -1);
            }
            p.del(idx.cat(Seek.FIELDS).key());
            p.del(idx.cat(Seek.TAGS).key());
            p.execute();
            Seek.getPool().returnResource(jedis);
        } catch (Exception e) {
            Seek.getPool().returnResource(jedis);
            throw new SeekException(e);
        }
View Full Code Here

            Set<String> range = jedis.zrange(rkeyCached, start, end);
            if (range != null && range.size() > 0) {
                count = jedis.zcard(rkeyCached);
                result = Arrays.asList(range.toArray(new String[range.size()]));
            } else {
                Pipeline pipeline = shard.pipelined();
                List<ConjunctiveFormula> dnf = DNF.convert(formulas);
                for (ConjunctiveFormula conjunctiveFormula : dnf) {
                    String[] keys = conjunctiveFormula.getLiterals()
                            .toArray(
                                    new String[conjunctiveFormula.getLiterals()
                                            .size()]);
                    pipeline.zinterstore(tmpkey, zparams, keys);
                    pipeline.zunionstore(rkey, zparams, tmpkey, rkey);
                }
                if (order.equals(Order.ASC)) {
                    pipeline.zrange(rkey, start, end);
                } else {
                    pipeline.zrevrange(rkey, start, end);
                }
                List<byte[]> rawresult = null;
                if (cache == 0) {
                    pipeline.del(rkey, tmpkey);
                    List<Object> execute = pipeline.execute();
                    // get zrange or zrevrange result
                    rawresult = (List<byte[]>) execute.get(execute.size() - 2);
                    // get the last zunionstore output, which is the number of
                    // elements in the result
                    count = (Long) execute.get(execute.size() - 3);
                } else {
                    pipeline.del(tmpkey);
                    pipeline.rename(rkey, rkeyCached);
                    pipeline.expire(rkeyCached, cache);
                    pipeline.del(rkey);
                    List<Object> execute = pipeline.execute();
                    // get zrange or zrevrange result
                    rawresult = (List<byte[]>) execute.get(execute.size() - 5);
                    // get the last zunionstore output, which is the number of
                    // elements in the result
                    count = (Long) execute.get(execute.size() - 6);
View Full Code Here

TOP

Related Classes of redis.clients.jedis.Pipeline$MultiResponseBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.