Skip to content

Commit

Permalink
test added
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Koksharov committed Aug 28, 2023
1 parent 6c1c007 commit 02e2bd8
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,46 @@
import org.redisson.api.RMap;
import org.redisson.api.RTransaction;
import org.redisson.api.TransactionOptions;
import org.redisson.api.map.MapLoader;

import java.util.HashMap;
import java.util.Map;

public class RedissonTransactionalLocalCachedMapTest extends BaseTest {


// reproducer for https://github.com/redisson/redisson/issues/5198
//@Test
public void test1() {
final LocalCachedMapOptions opts = LocalCachedMapOptions.defaults();
final Map<String, String> externalStore = new HashMap<>();
externalStore.put("hello", "world");
opts.loader(new MapLoader<String, String>() {
@Override
public String load(String key) {
return externalStore.get(key);
}

@Override
public Iterable loadAllKeys() {
return externalStore.keySet();
}
});

RLocalCachedMap lcMap = redisson.getLocalCachedMap("lcMap", opts);

// Uncomment the below line and hang will be avoided
// lcMap.get("hello");

RTransaction tx = redisson.createTransaction(TransactionOptions.defaults());
RLocalCachedMap txMap = tx.getLocalCachedMap(lcMap);

// Below line will hang for tx timeout period
txMap.fastRemove("hello");

// Commit will fail because tx has timed out
tx.commit();
}
@Test
public void testPut() throws InterruptedException {
RLocalCachedMap<String, String> m1 = redisson.getLocalCachedMap("test", LocalCachedMapOptions.defaults());
Expand Down

0 comments on commit 02e2bd8

Please sign in to comment.