一、代码示例
package com.my.test.redis;@b@@b@import java.util.List;@b@import java.util.Queue;@b@import java.util.Set;@b@import java.util.concurrent.ConcurrentMap;@b@@b@import org.redisson.Config;@b@import org.redisson.Redisson;@b@@b@public class RedisExample {@b@@b@ public static void main(String[] args) {@b@ @b@ Config config = new Config();@b@ config.setConnectionPoolSize(10);@b@ config.addAddress("127.0.0.1:6379");@b@ Redisson redisson = Redisson.create(config);@b@ System.out.println("reids session starting...");@b@ @b@ //test Map@b@ ConcurrentMap<String, Object> map = redisson.getMap("testMap");@b@ map.put("m_key1", "hello nj");@b@ map.put("m_key2", "hello ncs");@b@ map.put("m_key3", "hello cxy");@b@@b@ @b@ ConcurrentMap resultMap = redisson.getMap("testMap");@b@ System.out.println("resultMap Key:" + resultMap.keySet());@b@@b@ //test Set@b@ Set mySet = redisson.getSet("testSet");@b@ mySet.add("set111");@b@ mySet.add("set222");@b@@b@ Set resultSet = redisson.getSet("testSet");@b@ System.out.println("resultSet:" + resultSet.size());@b@ @b@ //test Queue@b@ Queue myQueue = redisson.getQueue("testQueue");@b@ myQueue.add("queue_111");@b@ myQueue.add("queue_222");@b@ myQueue.add("queue_333");@b@ myQueue.peek();@b@ myQueue.poll();@b@@b@ Queue resultQueue=redisson.getQueue("testQueue");@b@ System.out.println("resultQueue:"+resultQueue);@b@ @b@ //test List@b@ List myList=redisson.getList("testList");@b@ myList.add("list_111");@b@ myList.add("list_222");@b@ myList.add("list_333");@b@ @b@ List resultList=redisson.getList("testList");@b@ System.out.println("resultList:"+resultList);@b@ @b@ redisson.shutdown();@b@ }@b@@b@}
二、源码&相关下载
1.源码下载
2.redis下载