@themost /复述,
大多数Web框架Redis缓存模块
@themost/redis 的用法。 复述, 作为缓存策略a 大多数Web框架 应用程序。
安装
npm i @themost/redis
配置
添加 settings/redis 配置部分。
{
"settings": {
"redis": {
"options": {
"host": "127.0.0.1",
"port": 6379
},
"pool": {
"min": 2,
"max": 25
}
}
}
}
一节redis/options 包含配置与Redis服务器连接的选项。
阅读更多关于连接选项 ioredis
连接池
@themost/redis 使用 generic-pool 用于连接池。
配置 redis/pool 节设置要使用的最小和最大连接数。
阅读连接池选项 generic-pool
使用
配置要使用的应用服务 RedisCacheStrategy 作为缓存服务。
{
"services": [
{
"serviceType": "@themost/data#DataCacheStrategy",
"strategyType": "@themost/redis#RedisCacheStrategy"
}
]
}