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