@Author Lyp @Date 2020-06-23 @Email l1yp@qq.com
| 10 | * @Email l1yp@qq.com |
| 11 | */ |
| 12 | public class RedisKey { |
| 13 | private final String prefix; |
| 14 | private List<String> args; |
| 15 | private Duration expireTime; |
| 16 | private long expireAt; |
| 17 | private String cacheKey; |
| 18 | private Class<?> valType; |
| 19 | |
| 20 | RedisKey(String prefix){ |
| 21 | this.prefix = prefix; |
| 22 | } |
| 23 | |
| 24 | RedisKey(String prefix, Duration expireTime){ |
| 25 | this.prefix = prefix; |
| 26 | this.expireTime = expireTime; |
| 27 | } |
| 28 | |
| 29 | |
| 30 | RedisKey(String prefix, Duration expireTime, long expireAt, Class<?> valType){ |
| 31 | this.prefix = prefix; |
| 32 | this.expireTime = expireTime; |
| 33 | this.expireAt = expireAt; |
| 34 | this.valType = valType; |
| 35 | } |
| 36 | |
| 37 | |
| 38 | |
| 39 | /** |
| 40 | * 复制 前缀/过期时间 |
| 41 | * @return 返回新的redisKey实例 |
| 42 | */ |
| 43 | public RedisKey dup(){ |
| 44 | return new RedisKey(prefix, expireTime, expireAt, valType); |
| 45 | } |
| 46 | |
| 47 | |
| 48 | /** |
| 49 | * 拼接一个参数 |
| 50 | * @param arg 要拼接的参数 |
| 51 | */ |
| 52 | public RedisKey arg(Object arg) { |
| 53 | if (arg == null){ |
| 54 | throw new IllegalArgumentException("the arg must not be null"); |
| 55 | } |
| 56 | if (args == null) { |
| 57 | args = new ArrayList<>(4); |
| 58 | } |
| 59 | if (arg instanceof String) { |
| 60 | args.add((String) arg); |
| 61 | }else { |
| 62 | args.add(String.valueOf(arg)); |
| 63 | } |
| 64 | return this; |
| 65 | } |
| 66 | |
| 67 | public Class<?> getValType() { |
| 68 | return valType; |
| 69 | } |
nothing calls this directly
no outgoing calls
no test coverage detected