zbb378@sohu.com
2024-11-04 b2bad51be3c8d3e78d7f81a19415faeac2d0297c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//package com.nova.sankuai.infra.utils;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.stereotype.Component;
//
//import java.util.concurrent.TimeUnit;
//
///**
// * <p>
// * Redis部分操作封装
// * </p>
// *
// * @author Zhangjc
// * @since 2021/11/18
// */
//@Component
//public class RedisUtil {
//    private static final String PREFIX_KEY_APPID="check_appid_";
//
//    @Autowired
//    private StringRedisTemplate redisTemplate;
//
//    /**
//     * 把值存入redis
//     * @param key 要存储的key
//     * @param value 要存储的值
//     * @param timeout 超时时间(单位:毫秒),如果设置小于或等于0的超时时间将永不超时
//     */
//    public void setData(String key, String value, int timeout){
//        if(timeout>0){
//            redisTemplate.opsForValue().set(key,value,timeout, TimeUnit.MILLISECONDS);
//        }else{
//            redisTemplate.opsForValue().set(key,value);
//        }
//    }
//
//    /**
//     * 从redis中获取数据
//     * @param key 存储在redis中的key
//     * @return key对应的值
//     */
//    public String getData(String key){
//        return redisTemplate.opsForValue().get(key);
//    }
//
//    /**
//     * 从redis中清除指定的数据(1毫秒之后过期)
//     * @param key 待清除的key
//     */
//    public void cleanData(String key){
//        redisTemplate.expire(key,1,TimeUnit.MILLISECONDS);
//    }
//}