This repository has been archived on 2025-05-14. You can view files and clone it, but cannot push or open issues or pull requests.
copy-kamanote/src/main/java/com/example/copykamanotes/service/impl/RedisServiceImpl.java
LingandRX 341aadfe5a feat(model): 添加多个视图对象和 Redis 配置
- 新增 CategoryVO、CollectionVO、CommentVO 等多个视图对象
- 添加 RedisConfig 配置类
- 更新 RedisServiceImpl,移除不必要的 Qualifier 注解
- 修改 NoteMapper.xml,更新命名空间和结果映射
2025-03-31 22:25:12 +08:00

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