-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathRedisDao.java
More file actions
31 lines (23 loc) · 902 Bytes
/
RedisDao.java
File metadata and controls
31 lines (23 loc) · 902 Bytes
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
package com.dku.springstudy.config.security;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
import java.time.Duration;
@Component
public class RedisDao {
private final RedisTemplate<String, String> redisTemplate;
public RedisDao(RedisTemplate<String, String> redisTemplate) {
this.redisTemplate = redisTemplate;
}
public void setValues(String key, String data, Duration duration) {
ValueOperations<String, String> values = redisTemplate.opsForValue();
values.set(key, data, duration);
}
public String getValues(String key) {
ValueOperations<String, String> values = redisTemplate.opsForValue();
return values.get(key);
}
public void deleteValues(String key) {
redisTemplate.delete(key);
}
}