18
18
import org .springframework .util .Assert ;
19
19
20
20
/**
21
- * {@link CacheKeyPrefix} provides a hook for creating custom prefixes prepended to the actual {@literal key} stored in
22
- * Redis.
21
+ * {@link CacheKeyPrefix} is a callback hook for creating custom prefixes prepended to the actual {@literal key}
22
+ * stored in Redis.
23
23
*
24
24
* @author Christoph Strobl
25
25
* @author Mark Paluch
26
+ * @author John Blum
26
27
* @since 2.0.4
27
28
*/
28
29
@ FunctionalInterface
@@ -36,16 +37,20 @@ public interface CacheKeyPrefix {
36
37
String SEPARATOR = "::" ;
37
38
38
39
/**
39
- * Compute the prefix for the actual {@literal key} stored in Redis.
40
+ * Compute the {@link String prefix} for the actual {@literal cache key} stored in Redis.
40
41
*
41
- * @param cacheName will never be {@literal null}.
42
- * @return never {@literal null}.
42
+ * @param cacheName {@link String name} of the cache in which the key is stored;
43
+ * will never be {@literal null}.
44
+ * @return the computed {@link String prefix} of the {@literal cache key} stored in Redis;
45
+ * never {@literal null}.
43
46
*/
44
47
String compute (String cacheName );
45
48
46
49
/**
47
- * Creates a default {@link CacheKeyPrefix} scheme that prefixes cache keys with {@code cacheName} followed by double
48
- * colons. A cache named {@code myCache} will prefix all cache keys with {@code myCache::}.
50
+ * Creates a default {@link CacheKeyPrefix} scheme that prefixes cache keys with the {@link String name}
51
+ * of the cache followed by double colons.
52
+ *
53
+ * For example, a cache named {@literal myCache} will prefix all cache keys with {@literal myCache::}.
49
54
*
50
55
* @return the default {@link CacheKeyPrefix} scheme.
51
56
*/
@@ -54,9 +59,12 @@ static CacheKeyPrefix simple() {
54
59
}
55
60
56
61
/**
57
- * Creates a {@link CacheKeyPrefix} scheme that prefixes cache keys with the given {@code prefix}. The prefix is
58
- * prepended to the {@code cacheName} followed by double colons. A prefix {@code redis-} with a cache named
59
- * {@code myCache} results in {@code redis-myCache::}.
62
+ * Creates a {@link CacheKeyPrefix} scheme that prefixes cache keys with the given {@link String prefix}.
63
+ *
64
+ * The {@link String prefix} is prepended to the {@link String cacheName} followed by double colons.
65
+ *
66
+ * For example, a prefix {@literal redis-} with a cache named {@literal myCache}
67
+ * results in {@literal redis-myCache::}.
60
68
*
61
69
* @param prefix must not be {@literal null}.
62
70
* @return the default {@link CacheKeyPrefix} scheme.
@@ -65,6 +73,7 @@ static CacheKeyPrefix simple() {
65
73
static CacheKeyPrefix prefixed (String prefix ) {
66
74
67
75
Assert .notNull (prefix , "Prefix must not be null" );
76
+
68
77
return name -> prefix + name + SEPARATOR ;
69
78
}
70
79
}
0 commit comments