package com.stylefeng.guns.cache;

import com.alibaba.fastjson.JSON;
import com.stylefeng.guns.base.BaseTest;
import com.stylefeng.guns.common.constant.factory.ConstantFactory;
import com.stylefeng.guns.core.support.cache.CacheKit;
import org.junit.Test;

import java.util.List;

/**
 * 缓存测试
 *
 * @author fengshuonan
 * @date 2017-04-24 21:00
 */
public class CacheTest extends BaseTest{

    /**
     * 测试没有缓存的情况
     *
     * @author fengshuonan
     * @Date 2017/4/24 21:00
     */
    @Test
    public void testNoCache(){
        long beginTIme = System.currentTimeMillis();

        for(int i = 1;i<2000000;i++){
            String singleRoleName = ConstantFactory.me().getSingleRoleName(1);
        }
        System.out.println(System.currentTimeMillis() - beginTIme);

        Object constant = CacheKit.get("CONSTANT", "101");
        System.out.println(constant);

        List constant1 = CacheKit.getKeys("CONSTANT");
        System.out.println(JSON.toJSONString(constant1));


    }
}
