diff --git a/helenus-core.iml b/helenus-core.iml
index 77f2a38..241dc0e 100644
--- a/helenus-core.iml
+++ b/helenus-core.iml
@@ -11,8 +11,8 @@
-
-
+
+
@@ -20,7 +20,6 @@
-
@@ -38,6 +37,8 @@
+
+
@@ -113,7 +114,6 @@
-
diff --git a/pom.xml b/pom.xml
index 89abb41..df6db78 100644
--- a/pom.xml
+++ b/pom.xml
@@ -145,6 +145,21 @@
20.0
+
+
+ com.github.ben-manes.caffeine
+ caffeine
+ 2.5.3
+
+
+
+
+
+ io.dropwizard.metrics
+ metrics-core
+ 3.2.3
+
+
javax.validation
diff --git a/src/main/java/net/helenus/core/AbstractSessionOperations.java b/src/main/java/net/helenus/core/AbstractSessionOperations.java
index 36a5145..ffd1957 100644
--- a/src/main/java/net/helenus/core/AbstractSessionOperations.java
+++ b/src/main/java/net/helenus/core/AbstractSessionOperations.java
@@ -129,8 +129,7 @@ public abstract class AbstractSessionOperations {
}
}
- public void cache(String key, Object value) {
- }
+ public abstract void cache(String key, Object value);
RuntimeException translateException(RuntimeException e) {
diff --git a/src/main/java/net/helenus/core/HelenusSession.java b/src/main/java/net/helenus/core/HelenusSession.java
index 15cff2b..c84c3ef 100644
--- a/src/main/java/net/helenus/core/HelenusSession.java
+++ b/src/main/java/net/helenus/core/HelenusSession.java
@@ -15,20 +15,13 @@
*/
package net.helenus.core;
-import java.io.Closeable;
-import java.io.PrintStream;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.Executor;
-import java.util.concurrent.TimeUnit;
-import java.util.function.Function;
-
+import com.codahale.metrics.MetricRegistry;
import com.datastax.driver.core.*;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
import net.helenus.core.operation.*;
import net.helenus.core.reflect.HelenusPropertyNode;
+import net.helenus.mapping.ColumnType;
import net.helenus.mapping.HelenusEntity;
import net.helenus.mapping.MappingUtil;
import net.helenus.mapping.value.*;
@@ -37,10 +30,15 @@ import net.helenus.support.Fun.Tuple1;
import net.helenus.support.Fun.Tuple2;
import net.helenus.support.Fun.Tuple6;
-public final class HelenusSession extends AbstractSessionOperations implements Closeable {
+import java.io.Closeable;
+import java.io.PrintStream;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.Executor;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
- private final int MAX_CACHE_SIZE = 10000;
- private final int MAX_CACHE_EXPIRE_SECONDS = 600;
+public final class HelenusSession extends AbstractSessionOperations implements Closeable {
private final Session session;
private final CodecRegistry registry;
@@ -54,12 +52,13 @@ public final class HelenusSession extends AbstractSessionOperations implements C
private final RowColumnValueProvider valueProvider;
private final StatementColumnValuePreparer valuePreparer;
private final Metadata metadata;
- private final Cache sessionCache;
+ private final MetricRegistry metricRegistry;
+ private final Cache sessionCache;
private UnitOfWork currentUnitOfWork;
HelenusSession(Session session, String usingKeyspace, CodecRegistry registry, boolean showCql,
PrintStream printStream, SessionRepositoryBuilder sessionRepositoryBuilder, Executor executor,
- boolean dropSchemaOnClose) {
+ boolean dropSchemaOnClose, MetricRegistry metricRegistry) {
this.session = session;
this.registry = registry == null ? CodecRegistry.DEFAULT_INSTANCE : registry;
this.usingKeyspace = Objects.requireNonNull(usingKeyspace,
@@ -73,9 +72,16 @@ public final class HelenusSession extends AbstractSessionOperations implements C
this.valueProvider = new RowColumnValueProvider(this.sessionRepository);
this.valuePreparer = new StatementColumnValuePreparer(this.sessionRepository);
this.metadata = session.getCluster().getMetadata();
- this.sessionCache = CacheBuilder.newBuilder().maximumSize(MAX_CACHE_SIZE)
- .expireAfterAccess(MAX_CACHE_EXPIRE_SECONDS, TimeUnit.SECONDS).recordStats().build();
- this.currentUnitOfWork = null;
+ this.currentUnitOfWork = null;
+
+ this.metricRegistry = metricRegistry;
+ Caffeine