- 新增 CategoryVO、CollectionVO、CommentVO 等多个视图对象 - 添加 RedisConfig 配置类 - 更新 RedisServiceImpl,移除不必要的 Qualifier 注解 - 修改 NoteMapper.xml,更新命名空间和结果映射
53 lines
1.4 KiB
Java
53 lines
1.4 KiB
Java
package com.example.copykamanotes.service.impl;
|
|
|
|
import com.example.copykamanotes.service.RedisService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@Service
|
|
public class RedisServiceImpl implements RedisService {
|
|
@Autowired
|
|
private RedisTemplate<String, Object> redisTemplate;
|
|
|
|
@Override
|
|
public void set(String key, Object value) {
|
|
redisTemplate.opsForValue().set(key, value);
|
|
}
|
|
|
|
@Override
|
|
public void setWithExpire(String key, Object value, long expire) {
|
|
redisTemplate.opsForValue().set(key, value, expire);
|
|
}
|
|
|
|
@Override
|
|
public Object get(String key) {
|
|
return redisTemplate.opsForValue().get(key);
|
|
}
|
|
|
|
@Override
|
|
public void delete(String key) {
|
|
redisTemplate.delete(key);
|
|
}
|
|
|
|
@Override
|
|
public boolean exists(String key) {
|
|
return Boolean.TRUE.equals(redisTemplate.hasKey(key));
|
|
}
|
|
|
|
@Override
|
|
public Long increment(String key, long delta) {
|
|
return redisTemplate.opsForValue().increment(key, delta);
|
|
}
|
|
|
|
@Override
|
|
public Object getHashValue(String hashKey, String key) {
|
|
return redisTemplate.opsForHash().get(hashKey, key);
|
|
}
|
|
|
|
@Override
|
|
public void setHashValue(String hashKey, String key, Object value) {
|
|
redisTemplate.opsForHash().put(hashKey, key, value);
|
|
}
|
|
}
|