From 491333e1ee42a66c16ee7bf23883bd810f33cfd4 Mon Sep 17 00:00:00 2001 From: Andrew Golovashevich Date: Wed, 26 Mar 2025 19:55:41 +0300 Subject: [PATCH] Interface for different cache types --- .../PreparedStatementsCompilationCache.java | 12 ++++++++++++ .../PreparedStatementsCompilationPhantomCache.java | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/jvmMain/java/ru/langrafhomyak/db/jdbc_resources_manager/PreparedStatementsCompilationCache.java diff --git a/src/jvmMain/java/ru/langrafhomyak/db/jdbc_resources_manager/PreparedStatementsCompilationCache.java b/src/jvmMain/java/ru/langrafhomyak/db/jdbc_resources_manager/PreparedStatementsCompilationCache.java new file mode 100644 index 0000000..7f6c836 --- /dev/null +++ b/src/jvmMain/java/ru/langrafhomyak/db/jdbc_resources_manager/PreparedStatementsCompilationCache.java @@ -0,0 +1,12 @@ +package ru.langrafhomyak.db.jdbc_resources_manager; + +import org.jetbrains.annotations.NotNull; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +public interface PreparedStatementsCompilationCache { + @NotNull + PreparedStatement preparedStatementForConnection(@NotNull Connection connection) throws SQLException; +} diff --git a/src/jvmMain/java/ru/langrafhomyak/db/jdbc_resources_manager/PreparedStatementsCompilationPhantomCache.java b/src/jvmMain/java/ru/langrafhomyak/db/jdbc_resources_manager/PreparedStatementsCompilationPhantomCache.java index 28a7301..0f9a617 100644 --- a/src/jvmMain/java/ru/langrafhomyak/db/jdbc_resources_manager/PreparedStatementsCompilationPhantomCache.java +++ b/src/jvmMain/java/ru/langrafhomyak/db/jdbc_resources_manager/PreparedStatementsCompilationPhantomCache.java @@ -11,7 +11,7 @@ import java.sql.SQLException; import static java.lang.System.identityHashCode; -public class PreparedStatementsCompilationPhantomCache /*implements ReadOnlyProperty*/ { +public class PreparedStatementsCompilationPhantomCache implements PreparedStatementsCompilationCache { @NotNull private final String _statementSource; @NotNull @@ -22,6 +22,7 @@ public class PreparedStatementsCompilationPhantomCache /*implements ReadOnlyProp this._map = new _SynchronizedEmbedKeyHashMap<>(); } + @Override @NotNull public PreparedStatement preparedStatementForConnection(@NotNull Connection connection) throws SQLException { final int key = identityHashCode(connection);