//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);
|
// }
|
//}
|