您的位置:首页 > 其它

play framework学习笔记之 使用缓存cache

2011-04-18 15:48 375 查看

Use a cache

例子代码



public static void allProducts() {

List<Product> products = Cache.get("products", List.class);

if(products == null) {

products = Product.findAll();

Cache.set("products", products, "30mn");

}

render(products);

}



Cache就是一个缓存了数据的Map,你不能保证它永远生存。



Configure memcached

You can connect to a distributed cache by specifying multiple daemon addresses:

你可以连接到分布式的多个缓存进程,多个守护进程地址,这些进程可以有jobs来开启

[code]memcached=enabled
memcached.1.host=127.0.0.1:11211
memcached.2.host=127.0.0.1:11212


https://www.playframework.com/documentation/1.3.x/cache#api
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐