OperationBuilder.java
1.4 KB
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
32
33
34
35
36
37
38
39
40
41
42
package com.zhaoonline.redis.template;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundHashOperations;
import org.springframework.data.redis.core.BoundListOperations;
import org.springframework.data.redis.core.BoundSetOperations;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.RedisTemplate;
public class OperationBuilder<V> {
private RedisTemplate<String,V> redisTemplate;
@Autowired
public OperationBuilder(RedisTemplateFactory factory){
redisTemplate=factory.createTemplate();
redisTemplate.afterPropertiesSet();
}
public RedisTemplate<String,V> template(){
return this.redisTemplate;
}
public BoundValueOperations<String, V> builderValueOperations(String key){
BoundValueOperations<String, V> valeOper =redisTemplate.boundValueOps(key);
return valeOper;
}
public BoundSetOperations<String, V> builderSetOperations(String key){
BoundSetOperations<String, V> oper =redisTemplate.boundSetOps(key);
return oper;
}
public BoundListOperations<String, V> builderListOperations(String key){
BoundListOperations<String, V> oper =redisTemplate.boundListOps(key);
return oper;
}
public <HK,KV> BoundHashOperations<String, HK, KV> builderHashOperations(String key){
BoundHashOperations<String, HK,KV> oper =redisTemplate.boundHashOps(key);
return oper;
}
}