Redisson之RBoundedBlockingQueue

package bright.redisson;

import org.redisson.Redisson;
import org.redisson.api.RAtomicLong;
import org.redisson.api.RBoundedBlockingQueue;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.config.SingleServerConfig;

public class RBoundedBlockingQueueTest {

	public static void main(String[] args) {
		Config config = new Config();
		
		SingleServerConfig singleServerConfig = config.useSingleServer();
		singleServerConfig.setAddress("redis://127.0.0.1:6579");
		singleServerConfig.setPassword("9client!");
		
		RedissonClient redissonClient = Redisson.create(config);
		
		RBoundedBlockingQueue queue = redissonClient.getBoundedBlockingQueue("myRBoundedBlockingQueue");
		queue.trySetCapacity(100);
		
		queue.add("abc");
		queue.add("你好");
		
		System.out.println(queue.contains("你好"));
		queue.remove("abc");
		System.out.println(queue.contains("abc"));
		
		System.out.println("当前所剩容量:" + queue.remainingCapacity());
		
		redissonClient.shutdown();
	}

}

注意,要运行本程序,需要以下jar包:

1、jackson-annotations-2.9.6.jar

2、jackson-core-2.9.6.jar

3、jackson-databind-2.9.6.jar

4、jackson-dataformat-yaml-2.9.6.jar

5、log4j-1.2.17.jar

6、netty-all-4.1.28.Final.jar

7、redisson-3.7.5.jar

8、slf4j-api-1.7.25.jar

你可能感兴趣的:(Redisson)