use of org.redisson.api.listener.SetObjectListener in project redisson by redisson.
the class RedissonBucketTest method testSetListener.
@Test
public void testSetListener() throws FailedToStartRedisException, IOException, InterruptedException {
RedisProcess instance = new RedisRunner().nosave().randomPort().randomDir().notifyKeyspaceEvents(KEYSPACE_EVENTS_OPTIONS.E, KEYSPACE_EVENTS_OPTIONS.$).run();
Config config = new Config();
config.useSingleServer().setAddress(instance.getRedisServerAddressAndPort());
RedissonClient redisson = Redisson.create(config);
RBucket<Integer> al = redisson.getBucket("test");
CountDownLatch latch = new CountDownLatch(1);
al.addListener(new SetObjectListener() {
@Override
public void onSet(String name) {
latch.countDown();
}
});
al.set(1);
assertThat(latch.await(1, TimeUnit.SECONDS)).isTrue();
redisson.shutdown();
instance.stop();
}
Aggregations