1 package com.foxinmy.weixin4j.cache;
2
3 /**
4 * Cache的存储
5 *
6 * @className CacheStorager
7 * @author jinyu(foxinmy@gmail.com)
8 * @date 2015年6月22日
9 * @since JDK 1.6
10 * @see
11 */
12 public interface CacheStorager<T extends Cacheable> {
13 /**
14 * 考虑到临界情况,实际缓存的有效时间减去该毫秒数(60秒)
15 */
16 long CUTMS = 60 * 1000l;
17
18 /**
19 * 所有的缓存KEY
20 */
21 String ALLKEY = "weixin4j_cache_keys";
22
23 /**
24 * 查找缓存中的对象
25 *
26 * @param key
27 * 缓存key
28 * @return 缓存对象
29 */
30 T lookup(String key);
31
32 /**
33 * 缓存新的对象
34 *
35 * @param key
36 * 缓存key
37 *
38 * @param cache
39 * 将要缓存的对象
40 */
41 void caching(String key, T cache);
42
43 /**
44 * 移除缓存对象
45 *
46 * @param key
47 * 缓存key
48 * @return 移除的对象
49 */
50 T evict(String key);
51
52 /**
53 * 清除所有缓存对象(<font color="red">请慎重</font>)
54 *
55 */
56 void clear();
57 }