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
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
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