DATAREDIS-548 - Release connection after command execution in read-only transactions.
We now unbind and release the connection from the transaction resources after a Redis command is invoked. Redis read operations return always null while using RedisTemplate in a transaction so Redis read transactions are not useful. Previously, RedisConnection's were bound as transactional resource when used in the scope of a @Transactional(readOnly = true) method but not released on transaction completion. This was, because connections are not registered with a transaction synchronizer. Original Pull Request: #214
This commit is contained in:
committed by
Christoph Strobl
parent
b47fc350e0
commit
53c7f80676
@@ -39,6 +39,13 @@ import org.springframework.test.context.transaction.AfterTransaction;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Base class with integration tests for transactional use.
|
||||
*
|
||||
* @author Thomas Darimont
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(RelaxedJUnit4ClassRunner.class)
|
||||
@Transactional(transactionManager = "transactionManager")
|
||||
public abstract class AbstractTransactionalTestBase {
|
||||
@@ -129,6 +136,19 @@ public abstract class AbstractTransactionalTestBase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-548
|
||||
*/
|
||||
@Test
|
||||
@Transactional(readOnly = true)
|
||||
public void valueOperationShouldWorkWithReadOnlyTransactions() {
|
||||
|
||||
this.valuesShouldHaveBeenPersisted = false;
|
||||
for (String key : KEYS) {
|
||||
template.opsForValue().get(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-73
|
||||
*/
|
||||
@@ -146,7 +166,7 @@ public abstract class AbstractTransactionalTestBase {
|
||||
*/
|
||||
@Rollback(false)
|
||||
@Test
|
||||
public void listOperationLPushShoudBeCommittedCorrectly() {
|
||||
public void listOperationLPushShouldBeCommittedCorrectly() {
|
||||
|
||||
this.valuesShouldHaveBeenPersisted = true;
|
||||
for (String key : KEYS) {
|
||||
|
||||
Reference in New Issue
Block a user