package com.sckw.redis.utils;

import org.redisson.Redisson;
import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;

public class TestService {

    public void test(){
        Config config = new Config();
        config.useSingleServer()
                // use "rediss://" for SSL connection
                .setAddress("redis://39.104.183.141:6379").setPassword("123456");

        // or read config from file
        // config = Config.fromYAML(new File("config-file.yaml"));

        // 2. Create Redisson instance, support Sync and Async API
        RedissonClient redisson = Redisson.create(config);

        RBucket<Object> mytest = redisson.getBucket("mytest");
        mytest.set("value");
        System.out.println(mytest.get());
        mytest.set("value2");
        System.out.println(mytest.get());
        boolean b = mytest.compareAndSet("value2", "value3");
        System.out.println(mytest.get());
        boolean b1 = mytest.compareAndSet("value2", "value4");
        System.out.println(mytest.get());
    }

    public static void main(String[] args) {
        TestService testService = new TestService();
        testService.test();
    }
}
