|
|
@@ -22,6 +22,9 @@ public class AppCache {
|
|
|
@Autowired
|
|
|
private DbCache dbCache;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AppConfig appConfig;
|
|
|
+
|
|
|
/**
|
|
|
* 基本的なオブジェクトをキャッシュし、Integer、String、実体類等
|
|
|
*
|
|
|
@@ -31,7 +34,7 @@ public class AppCache {
|
|
|
public <T> void setCacheObject(final String key, final T value)
|
|
|
{
|
|
|
// データベースキャッシュ
|
|
|
- if(StringUtils.equals(AppConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
+ if(StringUtils.equals(appConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
dbCache.setCacheObject(key, value);
|
|
|
} else {
|
|
|
redisCache.setCacheObject(key, value);
|
|
|
@@ -50,7 +53,7 @@ public class AppCache {
|
|
|
public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit)
|
|
|
{
|
|
|
// データベースキャッシュ
|
|
|
- if(StringUtils.equals(AppConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
+ if(StringUtils.equals(appConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
dbCache.setCacheObject(key, value, timeout, timeUnit);
|
|
|
} else {
|
|
|
redisCache.setCacheObject(key, value, timeout, timeUnit);
|
|
|
@@ -67,7 +70,7 @@ public class AppCache {
|
|
|
public boolean expire(final String key, final long timeout)
|
|
|
{
|
|
|
// データベースキャッシュ
|
|
|
- if(StringUtils.equals(AppConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
+ if(StringUtils.equals(appConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
return dbCache.expire(key, timeout);
|
|
|
} else {
|
|
|
return redisCache.expire(key, timeout);
|
|
|
@@ -85,7 +88,7 @@ public class AppCache {
|
|
|
public boolean expire(final String key, final long timeout, final TimeUnit unit)
|
|
|
{
|
|
|
// データベースキャッシュ
|
|
|
- if(StringUtils.equals(AppConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
+ if(StringUtils.equals(appConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
return dbCache.expire(key, timeout, unit);
|
|
|
} else {
|
|
|
return redisCache.expire(key, timeout, unit);
|
|
|
@@ -100,7 +103,7 @@ public class AppCache {
|
|
|
*/
|
|
|
public long getExpire(final String key) {
|
|
|
// データベースキャッシュ
|
|
|
- if(StringUtils.equals(AppConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
+ if(StringUtils.equals(appConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
return dbCache.getExpire(key);
|
|
|
} else {
|
|
|
return redisCache.getExpire(key);
|
|
|
@@ -116,7 +119,7 @@ public class AppCache {
|
|
|
public Boolean hasKey(String key)
|
|
|
{
|
|
|
// データベースキャッシュ
|
|
|
- if(StringUtils.equals(AppConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
+ if(StringUtils.equals(appConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
return dbCache.hasKey(key);
|
|
|
} else {
|
|
|
return redisCache.hasKey(key);
|
|
|
@@ -132,7 +135,7 @@ public class AppCache {
|
|
|
public <T> T getCacheObject(final String key, Class<T> clazz)
|
|
|
{
|
|
|
// データベースキャッシュ
|
|
|
- if(StringUtils.equals(AppConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
+ if(StringUtils.equals(appConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
return dbCache.getCacheObject(key, clazz);
|
|
|
} else {
|
|
|
return redisCache.getCacheObject(key);
|
|
|
@@ -147,7 +150,7 @@ public class AppCache {
|
|
|
public boolean deleteObject(final String key)
|
|
|
{
|
|
|
// データベースキャッシュ
|
|
|
- if(StringUtils.equals(AppConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
+ if(StringUtils.equals(appConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
return dbCache.deleteObject(key);
|
|
|
} else {
|
|
|
return redisCache.deleteObject(key);
|
|
|
@@ -163,7 +166,7 @@ public class AppCache {
|
|
|
public boolean deleteObject(final Collection collection)
|
|
|
{
|
|
|
// データベースキャッシュ
|
|
|
- if(StringUtils.equals(AppConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
+ if(StringUtils.equals(appConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
return dbCache.deleteObject(collection);
|
|
|
} else {
|
|
|
return redisCache.deleteObject(collection);
|
|
|
@@ -179,7 +182,7 @@ public class AppCache {
|
|
|
public Collection<String> keys(final String pattern)
|
|
|
{
|
|
|
// データベースキャッシュ
|
|
|
- if(StringUtils.equals(AppConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
+ if(StringUtils.equals(appConfig.getCache(), CacheConstants.CACHE_TOOL_DB) ){
|
|
|
return dbCache.keys(pattern);
|
|
|
} else {
|
|
|
return redisCache.keys(pattern);
|