Redission入门

需要引入的 pom.xml


    org.redisson
    redisson
    3.5.4

——————————————————————————————————————————————

java代码

public class RedissionUtils {

    private RedissionUtils(){};

    private static RedissionUtils redissionUtils ;


    public static RedissionUtils getInstence(){
        if (redissionUtils == null ){
           synchronized (RedissionUtils.class){
               if (redissionUtils == null){
                   redissionUtils = new RedissionUtils() ;
               }
           }
        }
        return  redissionUtils ;
    }

    public RedissonClient getRedissionClient(){
        Config config = new Config();
        config.useSingleServer().setAddress("redis服务器地址及端口");
        RedissonClient redissionClient = Redisson.create(config);
        return  redissionClient ;
    }

    /**
     * 测试代码
     * @param args
     */
    public static void main(String[] args) {
        RedissonClient redissonClient =  RedissionUtils.getInstence().getRedissionClient();

        for (int i = 0 ; i < 100 ; i++){
            System.out.println(redissonClient.getQueue("queue").poll());
        }

        System.out.println(redissonClient.getQueue("queue").isExists());

    }


你可能感兴趣的:(Redission入门)