RedisTbTransactionalCache refactored to make doGet using the rawKey and the Redis connection precalculated slot based on hash

This commit is contained in:
Sergey Matvienko 2024-04-16 16:47:27 +02:00
parent 771d15a6dd
commit 034b480a6c

View File

@ -78,7 +78,7 @@ public abstract class RedisTbTransactionalCache<K extends Serializable, V extend
public TbCacheValueWrapper<V> get(K key) {
try (var connection = connectionFactory.getConnection()) {
byte[] rawKey = getRawKey(key);
byte[] rawValue = connection.stringCommands().get(rawKey);
byte[] rawValue = doGet(connection, rawKey);
if (rawValue == null) {
return null;
} else if (Arrays.equals(rawValue, BINARY_NULL_VALUE)) {
@ -95,6 +95,10 @@ public abstract class RedisTbTransactionalCache<K extends Serializable, V extend
}
}
protected byte[] doGet(RedisConnection connection, byte[] rawKey) {
return connection.stringCommands().get(rawKey);
}
@Override
public void put(K key, V value) {
try (var connection = connectionFactory.getConnection()) {