1 Star 0 Fork 953

jlcoding/jboot

forked from JbootProjects/jboot 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CacheTest.java 1.20 KB
一键复制 编辑 原始数据 按行查看 历史
Michael Yang 提交于 2018-07-17 11:12 +08:00 . 1.6.2-SNAPSHOT
import io.jboot.Jboot;
import io.jboot.core.cache.JbootCache;
import org.junit.Test;
import java.util.Arrays;
/**
* @author Michael Yang 杨福海 (fuhai999@gmail.com)
* @version V1.0
*/
public class CacheTest {
@Test
public void testSetAndGet() {
Jboot.setBootArg("jboot.cache.type", "ehcache");
JbootCache cache = Jboot.me().getCache();
cache.put("test", "mykey", "abc");
cache.get("test","mykey");
System.out.println((String) Jboot.me().getCache().get("test", "mykey"));
}
@Test
public void testSetInTimeAndGet() {
Jboot.setBootArg("jboot.cache.type", "ehredis");
Jboot.setBootArg("jboot.redis.host","127.0.0.1");
Jboot.me().getCache().put("test", 1, "abc", 2);
Jboot.me().getCache().put("test", "mykey", "abc", 2);
for (int i = 0; i < 4; i++) {
System.out.println(Arrays.toString(Jboot.me().getCache().getKeys("test").toArray()));
System.out.println(i + " : " + Jboot.me().getCache().get("test", "mykey"));
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/msgcode/jboot.git
git@gitee.com:msgcode/jboot.git
msgcode
jboot
jboot
master

搜索帮助