业务整合redis

 1 package com.imooc.miaosha.redis;
 2 
 3 public interface KeyPrefix {
 4       
 5    public int expireSeconds();
 6    
 7    public String getPrefix();
 8    
 9 }
10 //====================================
11 package com.imooc.miaosha.redis;
12 
13 public abstract class BasePrefix implements KeyPrefix{
14    
15    private int expireSeconds;
16    
17    private String prefix;
18    
19    public BasePrefix(String prefix) {//0代表永不过期
20       this(0, prefix);
21    }
22    
23    public BasePrefix( int expireSeconds, String prefix) {
24       this.expireSeconds = expireSeconds;
25       this.prefix = prefix;
26    }
27    
28    public int expireSeconds() {//默认0代表永不过期
29       return expireSeconds;
30    }
31 
32    public String getPrefix() {
33       String className = getClass().getSimpleName();
34       return className+":" + prefix;
35    }
36 
37 }

猜你喜欢

转载自www.cnblogs.com/Alexhuangqing/p/9471970.html