-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
Description
redis可视化工具
redis-windows
redis安装包
node_redis驱动
thinkjs中redis配置
thinkjs设置缓存并修改缓存类型:
export default class extends think.controller.base {
* indexAction(){
//设置缓存,缓存类型使用redis
yield this.cache("name", "value", {
type: "redis"
});
}
}
如何使用redis缓存
//获取缓存
think.cache("name").then(data => {});
//指定缓存类型获取,从 redis 里获取缓存
think.cache("name", undefined, {type: "redis"});
//如果缓存 userList 不存在,则查询数据库,并将值设置到缓存中
think.cache("userList", () => {
return think.model("user").select();
});
//设置缓存
think.cache("name", "value");
//删除缓存
think.cache("name", null);