Package redis.clients.jedis

Examples of redis.clients.jedis.Tuple


    }

    /** 删除最近消费的消息 */
    public void clean() {
        Set<Tuple> zrangeWithScores = JedisKit.zrangeWithScores(subscriber.key(), 0, 1);
        Tuple next = zrangeWithScores.iterator().next();
        Integer lowest = (int) next.getScore();
        String key = topic.cat("message").cat(lowest).key();
        logger.debug("clean key "+key);
        JedisKit.del(key);
    }
View Full Code Here


    private int getLastReadMessage() {
        Double lastMessageRead = JedisKit.zscore(subscriber.key(), id);
        if (lastMessageRead == null) {
            Set<Tuple> zrangeWithScores = JedisKit.zrangeWithScores(subscriber.key(), 0, 1);
            if (zrangeWithScores.iterator().hasNext()) {
                Tuple next = zrangeWithScores.iterator().next();
                Integer lowest = (int) next.getScore() - 1;
                JedisKit.zadd(subscriber.key(), lowest, id);
                return lowest;
            } else {
                return 0;
            }
View Full Code Here

  private List<LeaderData> massageLeaderData(String leaderboardName, Set<Tuple> memberData, boolean useZeroIndexForRank) {
    List<LeaderData> leaderData = new ArrayList<LeaderData>();
   
    Iterator<Tuple> memberDataIterator = memberData.iterator();
    while (memberDataIterator.hasNext()) {
      Tuple memberDataTuple = memberDataIterator.next();
      LeaderData leaderDataItem = new LeaderData(memberDataTuple.getElement(), memberDataTuple.getScore(), rankForIn(leaderboardName, memberDataTuple.getElement(), useZeroIndexForRank));
      leaderData.add(leaderDataItem);
    }
   
    return leaderData;
  }
View Full Code Here

        List<ChatMessages> chatMessages = new ArrayList<ChatMessages>();
        List<Object[]> seenUpdates = new ArrayList<Object[]>();
        List<Object[]> msgRemoves = new ArrayList<Object[]>();
        while (seenIterator.hasNext()){
            Tuple seen = seenIterator.next();
            Set<String> messageStrings = (Set<String>)resultsIterator.next();
            if (messageStrings.size() == 0){
                continue;
            }

            int seenId = 0;
            String chatId = seen.getElement();
            List<Map<String,Object>> messages = new ArrayList<Map<String,Object>>();
            for (String messageJson : messageStrings){
                Map<String,Object> message = (Map<String,Object>)gson.fromJson(
                    messageJson, new TypeToken<Map<String,Object>>(){}.getType());
                int messageId = ((Double)message.get("id")).intValue();
View Full Code Here

        }

        public void run() {
            while (!quit){
                Set<Tuple> items = conn.zrangeWithScores("delayed:", 0, 0);
                Tuple item = items.size() > 0 ? items.iterator().next() : null;
                if (item == null || item.getScore() > System.currentTimeMillis()) {
                    try{
                        sleep(10);
                    }catch(InterruptedException ie){
                        Thread.interrupted();
                    }
                    continue;
                }

                String json = item.getElement();
                String[] values = gson.fromJson(json, String[].class);
                String identifier = values[0];
                String queue = values[1];

                String locked = acquireLock(conn, identifier);
View Full Code Here

        result = targetAds(conn, new String[]{"VA"}, "wooooo");
        assert "2".equals(result.getValue1());

        Iterator<Tuple> range = conn.zrangeWithScores("idx:ad:value:", 0, -1).iterator();
        assert new Tuple("2", 0.125).equals(range.next());
        assert new Tuple("1", 0.25).equals(range.next());

        range = conn.zrangeWithScores("ad:base_value:", 0, -1).iterator();
        assert new Tuple("2", 0.125).equals(range.next());
        assert new Tuple("1", 0.25).equals(range.next());

        recordClick(conn, targetId, adId, false);

        range = conn.zrangeWithScores("idx:ad:value:", 0, -1).iterator();
        assert new Tuple("2", 0.125).equals(range.next());
        assert new Tuple("1", 2.5).equals(range.next());

        range = conn.zrangeWithScores("ad:base_value:", 0, -1).iterator();
        assert new Tuple("2", 0.125).equals(range.next());
        assert new Tuple("1", 0.25).equals(range.next());
    }
View Full Code Here

        public void run() {
            Gson gson = new Gson();
            while (!quit){
                Set<Tuple> range = conn.zrangeWithScores("schedule:", 0, 0);
                Tuple next = range.size() > 0 ? range.iterator().next() : null;
                long now = System.currentTimeMillis() / 1000;
                if (next == null || next.getScore() > now){
                    try {
                        sleep(50);
                    }catch(InterruptedException ie){
                        Thread.currentThread().interrupt();
                    }
                    continue;
                }

                String rowId = next.getElement();
                double delay = conn.zscore("delay:", rowId);
                if (delay <= 0) {
                    conn.zrem("delay:", rowId);
                    conn.zrem("schedule:", rowId);
                    conn.del("inv:" + rowId);
View Full Code Here

  private List<LeaderData> massageLeaderData(String leaderboardName, Set<Tuple> memberData, boolean useZeroIndexForRank) {
    List<LeaderData> leaderData = new ArrayList<LeaderData>();
   
    Iterator<Tuple> memberDataIterator = memberData.iterator();
    while (memberDataIterator.hasNext()) {
      Tuple memberDataTuple = memberDataIterator.next();
      LeaderData leaderDataItem = new LeaderData(memberDataTuple.getElement(), memberDataTuple.getScore(), rankForIn(leaderboardName, memberDataTuple.getElement(), useZeroIndexForRank));
      leaderData.add(leaderDataItem);
    }
   
    return leaderData;
  }
View Full Code Here

TOP

Related Classes of redis.clients.jedis.Tuple

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.