Skip to content
This repository was archived by the owner on Nov 21, 2020. It is now read-only.

Commit 1e2fcae

Browse files
committed
docs: add java doc
1 parent 5dadc87 commit 1e2fcae

File tree

5 files changed

+115
-0
lines changed

5 files changed

+115
-0
lines changed

src/main/java/org/code4everything/boot/cache/guava/GuavaCache.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,32 @@
1313
**/
1414
public class GuavaCache extends AbstractCache {
1515

16+
/**
17+
* @since 1.1.3
18+
*/
1619
private final com.google.common.cache.Cache<Object, Object> cache;
1720

21+
/**
22+
* 构造函数
23+
*
24+
* @param name 缓存名
25+
* @param cache {@link com.google.common.cache.Cache}
26+
*
27+
* @since 1.1.3
28+
*/
1829
public GuavaCache(String name, com.google.common.cache.Cache<Object, Object> cache) {
1930
super(name, cache);
2031
this.cache = cache;
2132
}
2233

34+
/**
35+
* 构造函数
36+
*
37+
* @param name 缓存名
38+
* @param cacheBuilder {@link CacheBuilder}
39+
*
40+
* @since 1.1.3
41+
*/
2342
public GuavaCache(String name, CacheBuilder<Object, Object> cacheBuilder) {
2443
this(name, cacheBuilder.build());
2544
}

src/main/java/org/code4everything/boot/cache/guava/GuavaCacheCreator.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,18 @@
1313
**/
1414
public class GuavaCacheCreator implements CacheCreator {
1515

16+
/**
17+
* @since 1.1.3
18+
*/
1619
protected final CacheBuilder<Object, Object> cacheBuilder;
1720

21+
/**
22+
* 构造函数
23+
*
24+
* @param cacheBuilder {@link CacheBuilder}
25+
*
26+
* @since 1.1.3
27+
*/
1828
public GuavaCacheCreator(CacheBuilder<Object, Object> cacheBuilder) {
1929
Objects.requireNonNull(cacheBuilder, "guava cache builder must not be null");
2030
this.cacheBuilder = cacheBuilder;

src/main/java/org/code4everything/boot/cache/redis/RedisCache.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,56 @@
1515
**/
1616
public class RedisCache extends AbstractCache {
1717

18+
/**
19+
* @since 1.1.3
20+
*/
1821
private final RedisTemplate<String, Object> redisTemplate;
1922

23+
/**
24+
* @since 1.1.3
25+
*/
2026
private final String keyPrefix;
2127

28+
/**
29+
* @since 1.1.3
30+
*/
2231
private final long timeout;
2332

33+
/**
34+
* 构造函数
35+
*
36+
* @param name 缓存名
37+
* @param redisTemplate {@link RedisTemplate}
38+
*
39+
* @since 1.1.3
40+
*/
2441
public RedisCache(String name, RedisTemplate<String, Object> redisTemplate) {
2542
this(name, redisTemplate, Long.MAX_VALUE, name);
2643
}
2744

45+
/**
46+
* 构造函数
47+
*
48+
* @param name 缓存名
49+
* @param redisTemplate {@link RedisTemplate}
50+
* @param timeout 过期时长
51+
*
52+
* @since 1.1.3
53+
*/
2854
public RedisCache(String name, RedisTemplate<String, Object> redisTemplate, long timeout) {
2955
this(name, redisTemplate, timeout, name);
3056
}
3157

58+
/**
59+
* 构造函数
60+
*
61+
* @param name 缓存名
62+
* @param redisTemplate {@link RedisTemplate}
63+
* @param timeout 过期时长
64+
* @param keyPrefix 键前缀
65+
*
66+
* @since 1.1.3
67+
*/
3268
public RedisCache(String name, RedisTemplate<String, Object> redisTemplate, long timeout, String keyPrefix) {
3369
super(name, redisTemplate);
3470
this.keyPrefix = keyPrefix + ":";
@@ -68,6 +104,14 @@ public void clear() {
68104
redisTemplate.delete(redisTemplate.keys(keyPrefix + "*"));
69105
}
70106

107+
/**
108+
* 在某个时间点过期
109+
*
110+
* @param key 键
111+
* @param date 日期
112+
*
113+
* @since 1.1.3
114+
*/
71115
public void expireAt(String key, Date date) {
72116
redisTemplate.expireAt(keyPrefix + key, date);
73117
}

src/main/java/org/code4everything/boot/cache/redis/RedisCacheCreator.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,55 @@
1414
**/
1515
public class RedisCacheCreator implements CacheCreator {
1616

17+
/**
18+
* @since 1.1.3
19+
*/
1720
protected final long timeout;
1821

22+
/**
23+
* @since 1.1.3
24+
*/
1925
protected final Map<String, String> prefixMap;
2026

27+
/**
28+
* 构造函数
29+
*
30+
* @since 1.1.3
31+
*/
2132
public RedisCacheCreator() {
2233
this(Long.MAX_VALUE, null);
2334
}
2435

36+
/**
37+
* 构造函数
38+
*
39+
* @param prefixMap 缓存名与缓存键前缀的映射(key is the name of the cache, value is cache's key prefix)
40+
*
41+
* @since 1.1.3
42+
*/
2543
public RedisCacheCreator(Map<String, String> prefixMap) {
2644
this(Long.MAX_VALUE, prefixMap);
2745
}
2846

47+
/**
48+
* 构造函数
49+
*
50+
* @param timeout 过期时长
51+
*
52+
* @since 1.1.3
53+
*/
2954
public RedisCacheCreator(long timeout) {
3055
this(timeout, null);
3156
}
3257

58+
/**
59+
* 构造函数
60+
*
61+
* @param timeout 过期时长
62+
* @param prefixMap 缓存名与缓存键前缀的映射(key is the name of the cache, value is cache's key prefix)
63+
*
64+
* @since 1.1.3
65+
*/
3366
public RedisCacheCreator(long timeout, Map<String, String> prefixMap) {
3467
this.timeout = timeout;
3568
this.prefixMap = prefixMap;

src/main/java/org/code4everything/boot/cache/redis/RedisCacheManager.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ public RedisCacheManager(Collection<RedisCache> caches) {
3232
this(caches, null);
3333
}
3434

35+
/**
36+
* 在某个时间点过期
37+
*
38+
* @param cacheName 缓存名
39+
* @param key 键
40+
* @param date 日期
41+
*
42+
* @since 1.1.3
43+
*/
3544
public void expireAt(String cacheName, String key, Date date) {
3645
Cache cache = getCache(cacheName);
3746
if (ObjectUtil.isNotNull(cache)) {

0 commit comments

Comments
 (0)