mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Remove deprecated methods on ServerCache getHitRatio() -> hitRatio(), getStatistics() -> statistics()
This commit is contained in:
+8
-15
@@ -1,5 +1,6 @@
|
||||
package io.ebean.cache;
|
||||
|
||||
import io.avaje.lang.Nullable;
|
||||
import io.ebean.meta.MetricVisitor;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -68,36 +69,27 @@ public interface ServerCache {
|
||||
/**
|
||||
* Return the number of entries in the cache.
|
||||
*/
|
||||
int size();
|
||||
default int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the hit ratio the cache is currently getting.
|
||||
*/
|
||||
default int hitRatio() {
|
||||
return getHitRatio();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated migrate to hitRatio().
|
||||
*/
|
||||
@Deprecated
|
||||
int getHitRatio();
|
||||
|
||||
/**
|
||||
* Return statistics for the cache.
|
||||
*
|
||||
* @param reset if true the statistics are reset.
|
||||
*/
|
||||
@Nullable
|
||||
default ServerCacheStatistics statistics(boolean reset) {
|
||||
return getStatistics(reset);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated migrate to statistics().
|
||||
*/
|
||||
@Deprecated
|
||||
ServerCacheStatistics getStatistics(boolean reset);
|
||||
|
||||
/**
|
||||
* Visit the metrics for the cache.
|
||||
*/
|
||||
@@ -108,6 +100,7 @@ public interface ServerCache {
|
||||
/**
|
||||
* Unwrap the underlying ServerCache.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
default <T> T unwrap(Class<T> cls) {
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@@ -69,13 +69,13 @@ public final class TenantAwareCache implements ServerCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHitRatio() {
|
||||
return delegate.getHitRatio();
|
||||
public int hitRatio() {
|
||||
return delegate.hitRatio();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerCacheStatistics getStatistics(boolean reset) {
|
||||
return delegate.getStatistics(reset);
|
||||
public ServerCacheStatistics statistics(boolean reset) {
|
||||
return delegate.statistics(reset);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,7 +45,7 @@ class TenantAwareCacheTest {
|
||||
|
||||
@Test
|
||||
void putAll_getAll_removeAll() {
|
||||
Map<Object,Object> map = new HashMap<>();
|
||||
Map<Object, Object> map = new HashMap<>();
|
||||
map.put("A", "a");
|
||||
map.put("B", "b");
|
||||
map.put("C", "c");
|
||||
@@ -109,14 +109,5 @@ class TenantAwareCacheTest {
|
||||
return map.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHitRatio() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerCacheStatistics getStatistics(boolean reset) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -85,7 +85,7 @@ public class DefaultServerCache implements ServerCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerCacheStatistics getStatistics(boolean reset) {
|
||||
public ServerCacheStatistics statistics(boolean reset) {
|
||||
ServerCacheStatistics cacheStats = new ServerCacheStatistics();
|
||||
cacheStats.setCacheName(name);
|
||||
cacheStats.setMaxSize(maxSize);
|
||||
@@ -114,7 +114,7 @@ public class DefaultServerCache implements ServerCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHitRatio() {
|
||||
public int hitRatio() {
|
||||
long mc = missCount.get(false);
|
||||
long hc = hitCount.get(false);
|
||||
long totalCount = hc + mc;
|
||||
|
||||
@@ -141,18 +141,4 @@ public final class DuelCache implements ServerCache, NearCacheInvalidate {
|
||||
return remote.getMissCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHitRatio() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerCacheStatistics getStatistics(boolean reset) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,17 +277,7 @@ final class RedisCache implements ServerCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHitRatio() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerCacheStatistics getStatistics(boolean reset) {
|
||||
public ServerCacheStatistics statistics(boolean reset) {
|
||||
ServerCacheStatistics cacheStats = new ServerCacheStatistics();
|
||||
cacheStats.setCacheName(cacheKey);
|
||||
cacheStats.setHitCount(hitCount.get(reset));
|
||||
|
||||
Reference in New Issue
Block a user