diff --git a/src/main/java/org/springframework/data/redis/cache/RedisCache.java b/src/main/java/org/springframework/data/redis/cache/RedisCache.java index 95ca9c0d0..424e7e581 100644 --- a/src/main/java/org/springframework/data/redis/cache/RedisCache.java +++ b/src/main/java/org/springframework/data/redis/cache/RedisCache.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2014 the original author or authors. + * Copyright 2011-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ import org.springframework.util.Assert; * @author Thomas Darimont */ @SuppressWarnings("unchecked") -class RedisCache implements Cache { +public class RedisCache implements Cache { private static final int PAGE_SIZE = 128; private final String name; @@ -56,7 +56,8 @@ class RedisCache implements Cache { * @param template * @param expiration */ - RedisCache(String name, byte[] prefix, RedisTemplate template, long expiration) { + public RedisCache(String name, byte[] prefix, RedisTemplate template, + long expiration) { Assert.hasText(name, "non-empty cache name is required"); this.name = name; diff --git a/src/main/java/org/springframework/data/redis/cache/RedisCacheManager.java b/src/main/java/org/springframework/data/redis/cache/RedisCacheManager.java index d988ff460..fff19c4ae 100644 --- a/src/main/java/org/springframework/data/redis/cache/RedisCacheManager.java +++ b/src/main/java/org/springframework/data/redis/cache/RedisCacheManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2014 the original author or authors. + * Copyright 2011-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -176,7 +176,7 @@ public class RedisCacheManager extends AbstractTransactionSupportingCacheManager * @param caches must not be {@literal null} * @return */ - private Collection addConfiguredCachesIfNecessary(Collection caches) { + protected Collection addConfiguredCachesIfNecessary(Collection caches) { Assert.notNull(caches, "Caches must not be null!"); @@ -202,18 +202,18 @@ public class RedisCacheManager extends AbstractTransactionSupportingCacheManager return result; } - private Cache createAndAddCache(String cacheName) { + protected Cache createAndAddCache(String cacheName) { addCache(createCache(cacheName)); return super.getCache(cacheName); } @SuppressWarnings("unchecked") - private RedisCache createCache(String cacheName) { + protected RedisCache createCache(String cacheName) { long expiration = computeExpiration(cacheName); return new RedisCache(cacheName, (usePrefix ? cachePrefix.prefix(cacheName) : null), template, expiration); } - private long computeExpiration(String name) { + protected long computeExpiration(String name) { Long expiration = null; if (expires != null) { expiration = expires.get(name); @@ -221,9 +221,9 @@ public class RedisCacheManager extends AbstractTransactionSupportingCacheManager return (expiration != null ? expiration.longValue() : defaultExpiration); } - private List loadAndInitRemoteCaches() { + protected List loadAndInitRemoteCaches() { - List caches = new ArrayList(); + List caches = new ArrayList(); try { Set cacheNames = loadRemoteCacheKeys(); @@ -244,7 +244,7 @@ public class RedisCacheManager extends AbstractTransactionSupportingCacheManager } @SuppressWarnings("unchecked") - private Set loadRemoteCacheKeys() { + protected Set loadRemoteCacheKeys() { return (Set) template.execute(new RedisCallback>() { @Override @@ -264,4 +264,17 @@ public class RedisCacheManager extends AbstractTransactionSupportingCacheManager } }); } + + @SuppressWarnings("rawtypes") + protected RedisTemplate getTemplate() { + return template; + } + + protected RedisCachePrefix getCachePrefix() { + return cachePrefix; + } + + protected boolean isUsePrefix() { + return usePrefix; + } }