Package redis.clients.jedis

Examples of redis.clients.jedis.Transaction.exec()


        Set<String> words = tokenize(content);
        Transaction trans = conn.multi();
        for (String word : words) {
            trans.sadd("idx:" + word, docid);
        }
        return trans.exec().size();
    }

    private String setCommon(
        Transaction trans, String method, int ttl, String... items)
    {
View Full Code Here


        List<String> toIntersect = new ArrayList<String>();
        for (List<String> syn : query.all) {
            if (syn.size() > 1) {
                Transaction trans = conn.multi();
                toIntersect.add(union(trans, ttl, syn.toArray(new String[syn.size()])));
                trans.exec();
            }else{
                toIntersect.add(syn.get(0));
            }
        }
View Full Code Here

        String intersectResult = null;
        if (toIntersect.size() > 1) {
            Transaction trans = conn.multi();
            intersectResult = intersect(
                trans, ttl, toIntersect.toArray(new String[toIntersect.size()]));
            trans.exec();
        }else{
            intersectResult = toIntersect.get(0);
        }

        if (!query.unwanted.isEmpty()) {
View Full Code Here

            String[] keys = query.unwanted
                .toArray(new String[query.unwanted.size() + 1]);
            keys[keys.length - 1] = intersectResult;
            Transaction trans = conn.multi();
            intersectResult = difference(trans, ttl, keys);
            trans.exec();
        }

        return intersectResult;
    }
View Full Code Here

            params.alpha();
        }
        params.by(by);
        params.limit(0, 20);
        trans.sort("idx:" + id, params);
        List<Object> results = trans.exec();

        return new SearchResult(
            id,
            ((Long)results.get(0)).longValue(),
            (List<String>)results.get(1));
View Full Code Here

        if (desc) {
            trans.zrevrange("idx:" + id, start, start + num - 1);
        }else{
            trans.zrange("idx:" + id, start, start + num - 1);
        }
        List<Object> results = trans.exec();

        return new SearchResult(
            id,
            ((Long)results.get(results.size() - 2)).longValue(),
            // Note: it's a LinkedHashSet, so it's ordered
View Full Code Here

        trans.zadd("idx:ad:value:", rvalue, id);
        trans.zadd("ad:base_value:", value, id);
        for (String word : words){
            trans.sadd("terms:" + id, word);
        }
        trans.exec();
    }

    public double toEcpm(Ecpm type, double views, double avg, double value) {
        switch(type){
            case CPC:
View Full Code Here

            trans, matchedAds, baseEcpm, content);

        trans.incr("ads:served:");
        trans.zrevrange("idx:" + result.getValue1(), 0, 0);

        List<Object> response = trans.exec();
        long targetId = (Long)response.get(response.size() - 2);
        Set<String> targetedAds = (Set<String>)response.get(response.size() - 1);

        if (targetedAds.size() == 0){
            return new Pair<Long,String>(null, null);
View Full Code Here

        for (String term : terms) {
            trans.zincrby("views:" + adId, 1, term);
        }
        trans.zincrby("views:" + adId, 1, "");

        List<Object> response = trans.exec();
        double views = (Double)response.get(response.size() - 1);
        if ((views % 100) == 0){
            updateCpms(conn, adId);
        }
    }
View Full Code Here

    public void updateCpms(Jedis conn, String adId) {
        Transaction trans = conn.multi();
        trans.hget("type:", adId);
        trans.zscore("ad:base_value:", adId);
        trans.smembers("terms:" + adId);
        List<Object> response = trans.exec();
        String type = (String)response.get(0);
        Double baseValue = (Double)response.get(1);
        Set<String> words = (Set<String>)response.get(2);

        String which = "clicks";
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.