Beispiel #1
0
 def add_msg_cache(messages, room_id):
     chat_queue_name = chat_queue_prefix + str(room_id)
     if c.llen(chat_queue_name) >= MessageCacheManager.get_room_cache_size(
             room_id):
         c.lpop(chat_queue_name)
     c.rpush(chat_queue_name, messages)
     return True
Beispiel #2
0
 def get_msg_for_room_id(room_id):
     chat_queue_name = chat_queue_prefix + str(room_id)
     queue_len = c.llen(chat_queue_name)
     if not queue_len:
         return list()
     
     msg_list = c.lrange(chat_queue_name, 0, -1)
     
     lists = list()
     for msg in msg_list:
         lists.append(eval(msg)[0])
     return lists
Beispiel #3
0
    def get_msg_for_room_id(room_id):
        chat_queue_name = chat_queue_prefix + str(room_id)
        queue_len = c.llen(chat_queue_name)
        if not queue_len:
            return list()

        msg_list = c.lrange(chat_queue_name, 0, -1)

        lists = list()
        for msg in msg_list:
            lists.append(eval(msg)[0])
        return lists
Beispiel #4
0
 def add_msg_cache(messages, room_id):
     chat_queue_name =  chat_queue_prefix + str(room_id)
     if c.llen(chat_queue_name) >= MessageCacheManager.get_room_cache_size(room_id):
         c.lpop(chat_queue_name)
     c.rpush(chat_queue_name, messages)
     return True