Improvement - hibernate cache should read data from Redis slave if idleTime and cache size weren't specified. #2981

pull/3562/head
Nikita Koksharov 4 years ago
parent c94e6d668f
commit b19f30c567

@ -48,6 +48,7 @@ public class BaseRegion implements TransactionalDataRegion, GeneralDataRegion {
int ttl;
int maxIdle;
int size;
boolean fallback;
volatile boolean fallbackMode;
@ -60,7 +61,8 @@ public class BaseRegion implements TransactionalDataRegion, GeneralDataRegion {
String maxEntries = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_ENTRIES_SUFFIX);
if (maxEntries != null) {
mapCache.setMaxSize(Integer.valueOf(maxEntries));
size = Integer.valueOf(maxEntries);
mapCache.setMaxSize(size);
}
String timeToLive = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.TTL_SUFFIX);
if (timeToLive != null) {
@ -180,6 +182,9 @@ public class BaseRegion implements TransactionalDataRegion, GeneralDataRegion {
return null;
}
try {
if (maxIdle == 0 && size == 0) {
return mapCache.getWithTTLOnly(key);
}
return mapCache.get(key);
} catch (Exception e) {
if (fallback) {

@ -49,6 +49,7 @@ public class BaseRegion implements TransactionalDataRegion, GeneralDataRegion {
int ttl;
int maxIdle;
int size;
boolean fallback;
volatile boolean fallbackMode;
@ -61,7 +62,8 @@ public class BaseRegion implements TransactionalDataRegion, GeneralDataRegion {
String maxEntries = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_ENTRIES_SUFFIX);
if (maxEntries != null) {
mapCache.setMaxSize(Integer.valueOf(maxEntries));
size = Integer.valueOf(maxEntries);
mapCache.setMaxSize(size);
}
String timeToLive = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.TTL_SUFFIX);
if (timeToLive != null) {
@ -181,6 +183,9 @@ public class BaseRegion implements TransactionalDataRegion, GeneralDataRegion {
return null;
}
try {
if (maxIdle == 0 && size == 0) {
return mapCache.getWithTTLOnly(key);
}
return mapCache.get(key);
} catch (Exception e) {
if (fallback) {

@ -49,6 +49,7 @@ public class BaseRegion implements TransactionalDataRegion, GeneralDataRegion {
int ttl;
int maxIdle;
int size;
boolean fallback;
volatile boolean fallbackMode;
@ -61,7 +62,8 @@ public class BaseRegion implements TransactionalDataRegion, GeneralDataRegion {
String maxEntries = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_ENTRIES_SUFFIX);
if (maxEntries != null) {
mapCache.setMaxSize(Integer.valueOf(maxEntries));
size = Integer.valueOf(maxEntries);
mapCache.setMaxSize(size);
}
String timeToLive = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.TTL_SUFFIX);
if (timeToLive != null) {
@ -181,6 +183,9 @@ public class BaseRegion implements TransactionalDataRegion, GeneralDataRegion {
return null;
}
try {
if (maxIdle == 0 && size == 0) {
return mapCache.getWithTTLOnly(key);
}
return mapCache.get(key);
} catch (Exception e) {
if (fallback) {

@ -42,6 +42,7 @@ public class RedissonStorage implements DomainDataStorageAccess {
int ttl;
int maxIdle;
int size;
boolean fallback;
volatile boolean fallbackMode;
@ -52,7 +53,8 @@ public class RedissonStorage implements DomainDataStorageAccess {
String maxEntries = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.MAX_ENTRIES_SUFFIX);
if (maxEntries != null) {
mapCache.setMaxSize(Integer.valueOf(maxEntries));
size = Integer.valueOf(maxEntries);
mapCache.setMaxSize(size);
}
String timeToLive = getProperty(properties, mapCache.getName(), defaultKey, RedissonRegionFactory.TTL_SUFFIX);
if (timeToLive != null) {
@ -99,6 +101,10 @@ public class RedissonStorage implements DomainDataStorageAccess {
return null;
}
try {
if (maxIdle == 0 && size == 0) {
return mapCache.getWithTTLOnly(key);
}
return mapCache.get(key);
} catch (Exception e) {
if (fallback) {

Loading…
Cancel
Save