Skip to content

Commit c12d3ed

Browse files
committed
Caching - properly bypass the cache for queries that return non ResultSet objects
1 parent d568839 commit c12d3ed

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

wrapper/src/main/java/software/amazon/jdbc/plugin/cache/DataRemoteCachePlugin.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,12 @@ public <T, E extends Exception> T execute(
252252
final JdbcCallable<T, E> jdbcMethodFunc,
253253
final Object[] jdbcMethodArgs)
254254
throws E {
255+
if (resultClass != ResultSet.class) {
256+
return jdbcMethodFunc.call();
257+
}
258+
259+
incrCounter(totalQueryCounter);
260+
255261
ResultSet result;
256262
boolean needToCache = false;
257263
final String sql = getQuery(jdbcMethodArgs);
@@ -273,8 +279,6 @@ public <T, E extends Exception> T execute(
273279
}
274280
}
275281

276-
incrCounter(totalQueryCounter);
277-
278282
// Query result can be served from the cache if it has a configured TTL value, and it is
279283
// not executed in a transaction as a transaction typically need to return consistent results.
280284
if (!isInTransaction && (configuredQueryTtl != null)) {

0 commit comments

Comments
 (0)