移除已废弃的RedisConfig和RedisService
This commit is contained in:
-76
@@ -1,76 +0,0 @@
|
||||
package cn.novalon.gym.manage.groupcourse.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author:liwentao
|
||||
* @date:2026/5/15-05-15-16:05
|
||||
*/
|
||||
@Service
|
||||
public class RedisService {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
// 设置值
|
||||
public void set(String key, Object value) {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
}
|
||||
|
||||
// 设置值并指定过期时间(秒)
|
||||
public void setWithExpire(String key, Object value, long timeout) {
|
||||
redisTemplate.opsForValue().set(key, value, timeout, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
// 获取值
|
||||
public Object get(String key) {
|
||||
return redisTemplate.opsForValue().get(key);
|
||||
}
|
||||
|
||||
// 删除key
|
||||
public Boolean delete(String key) {
|
||||
return redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
// 判断key是否存在
|
||||
public Boolean hasKey(String key) {
|
||||
return redisTemplate.hasKey(key);
|
||||
}
|
||||
|
||||
// 设置过期时间
|
||||
public Boolean expire(String key, long timeout) {
|
||||
return redisTemplate.expire(key, timeout, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
// Hash操作
|
||||
public void putHash(String key, String hashKey, Object value) {
|
||||
redisTemplate.opsForHash().put(key, hashKey, value);
|
||||
}
|
||||
|
||||
public Object getHash(String key, String hashKey) {
|
||||
return redisTemplate.opsForHash().get(key, hashKey);
|
||||
}
|
||||
|
||||
// List操作
|
||||
public void leftPush(String key, Object value) {
|
||||
redisTemplate.opsForList().leftPush(key, value);
|
||||
}
|
||||
|
||||
public Object rightPop(String key) {
|
||||
return redisTemplate.opsForList().rightPop(key);
|
||||
}
|
||||
|
||||
// Set操作
|
||||
public void addToSet(String key, Object... values) {
|
||||
redisTemplate.opsForSet().add(key, values);
|
||||
}
|
||||
|
||||
public Set<Object> getSet(String key) {
|
||||
return redisTemplate.opsForSet().members(key);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user