|  |  | 
 |  |  | import java.util.*;
 | 
 |  |  | import java.util.concurrent.TimeUnit;
 | 
 |  |  | 
 | 
 |  |  | import com.alibaba.fastjson.JSONObject;
 | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
 |  |  | import org.springframework.data.redis.core.*;
 | 
 |  |  | import org.springframework.stereotype.Component;
 | 
 |  |  | 
 |  |  |     }
 | 
 |  |  | 
 | 
 |  |  |     /**
 | 
 |  |  |      * 在键为 key 的 list中移除第一个元素
 | 
 |  |  |      * @param key 键
 | 
 |  |  |      * @return
 | 
 |  |  |      */
 | 
 |  |  |     public Object lLeftPop(String key) {
 | 
 |  |  |         return redisTemplate.opsForList().leftPop(key);
 | 
 |  |  |     }
 | 
 |  |  | 
 | 
 |  |  |     /**
 | 
 |  |  |      * 在键为 key 的 list中移除、最后一个元素
 | 
 |  |  |      * @param key 键
 | 
 |  |  |      * @return
 | 
 |  |  |      */
 | 
 |  |  |     public Object lrightPop(String key) {
 | 
 |  |  |         return redisTemplate.opsForList().rightPop(key);
 | 
 |  |  |     }
 | 
 |  |  | 
 | 
 |  |  |     /**
 | 
 |  |  |      * 模糊查询
 | 
 |  |  |      * @param key 键
 | 
 |  |  |      * @return true / false
 | 
 |  |  | 
 |  |  |     }
 | 
 |  |  | 
 | 
 |  |  |     //    ============================== 消息发送与订阅 ==============================
 | 
 |  |  |     public void convertAndSend(String channel, String msg) {
 | 
 |  |  |     public void convertAndSend(String channel, JSONObject msg) {
 | 
 |  |  | //        redisTemplate.convertAndSend(channel, msg);
 | 
 |  |  |         redisTemplate.convertAndSend(channel, msg);
 | 
 |  |  | 
 | 
 |  |  |     }
 |