From 7e7f901b2172281dc294dfbc67e6ad00625f09f4 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期一, 04 三月 2024 10:11:21 +0800
Subject: [PATCH] 合并代码

---
 cloud-server-management/src/main/java/com/dsh/course/util/RedisUtil.java |  125 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 125 insertions(+), 0 deletions(-)

diff --git a/cloud-server-management/src/main/java/com/dsh/course/util/RedisUtil.java b/cloud-server-management/src/main/java/com/dsh/course/util/RedisUtil.java
new file mode 100644
index 0000000..cd975dc
--- /dev/null
+++ b/cloud-server-management/src/main/java/com/dsh/course/util/RedisUtil.java
@@ -0,0 +1,125 @@
+//package com.dsh.app.util;
+//
+//import com.alibaba.csp.sentinel.util.StringUtil;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.stereotype.Component;
+//import redis.clients.jedis.Jedis;
+//import redis.clients.jedis.JedisPool;
+//import redis.clients.jedis.Pipeline;
+//
+//import java.io.IOException;
+//import java.util.ArrayList;
+//import java.util.List;
+//
+//
+///**
+// * Redis工具类
+// */
+//@Component
+//public class RedisUtil {
+//
+//    @Autowired
+//    private JedisPool jedisPool;
+//
+//
+//    /**
+//     * 向redis中存储字符串没有过期时间
+//     * @param key
+//     * @param value
+//     */
+//    public void setStrValue(String key, String value){
+//        if(StringUtil.isNotEmpty(key)){
+//            Jedis resource = jedisPool.getResource();
+//            String set = resource.set(key, value);
+//            closeJedis(resource);
+//        }
+//    }
+//
+//
+//    /**
+//     * 以分钟为单位设置存储值(设置过期时间)
+//     * @param key
+//     * @param value
+//     * @param time 秒
+//     */
+//    public void setStrValue(String key, String value, int time){
+//        if(StringUtil.isNotEmpty(key)){
+//            Jedis resource = jedisPool.getResource();
+//            String setex = resource.setex(key, time, value);
+//            closeJedis(resource);
+//        }
+//    }
+//
+//
+//    /**
+//     * 从redis中获取值
+//     * @param key
+//     * @return
+//     */
+//    public String getValue(String key){
+//        if(StringUtil.isNotEmpty(key)){
+//            Jedis resource = jedisPool.getResource();
+//            String data = resource.get(key);
+//            closeJedis(resource);
+//            return data;
+//        }
+//        return null;
+//    }
+//
+//
+//    /**
+//     * 批量获取
+//     * @param kes
+//     * @return
+//     */
+//    public List<Object> getValues(List<String> kes){
+//        if(null != kes){
+//            Jedis resource = jedisPool.getResource();
+//            Pipeline pipelined = resource.pipelined();
+//            for(String key : kes){
+//                pipelined.get(key);
+//            }
+//            List<Object> list = pipelined.syncAndReturnAll();
+//
+//            closeJedis(resource);
+//            pipelined.clear();
+//            try {
+//                pipelined.close();
+//            } catch (IOException e) {
+//                e.printStackTrace();
+//            }
+//            List<Object> data = new ArrayList<>();
+//            for(Object o : list){
+//                if(null != o){
+//                    data.add(o);
+//                }
+//            }
+//            return data;
+//        }
+//        return null;
+//    }
+//
+//
+//    /**
+//     * 删除key
+//     * @param key
+//     */
+//    public void remove(String key){
+//        if(StringUtil.isNotEmpty(key)){
+//            Jedis resource = jedisPool.getResource();
+//            Long del = resource.del(key);
+//            closeJedis(resource);
+//        }
+//    }
+//
+//
+//    /**
+//     * 删除资源
+//     * @param jedis
+//     */
+//    public void closeJedis(Jedis jedis){
+//        if(null != jedis){
+//            jedis.close();
+//        }
+//    }
+//}

--
Gitblit v1.7.1