最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

NestJs 缓存管理器问题

网站源码admin40浏览0评论

NestJs 缓存管理器问题

NestJs 缓存管理器问题

我在尝试使用 NestJS 的缓存管理器时遇到了问题, 问题是值总是返回

true
,

const isSet = await this.cacheManager.store.getClient().set(key, value, 'EX', ttl, 'NX')
console.log("isSet => " + lockExists)

if(lockExists === true) {
  try {
      //do smth
  } catch(err) {
     console.log("err => " + err)
     throw err;
  } finally {
    //await this.cacheManager.del(key);
  }
}

我的问题是,当我重复使用 redis-cli 时

set key val ex ttl nx

不存在则返回OK,存在则返回nil。

为什么缓存管理器一直返回 true?

依赖版本

"cache-manager": "^3.6.0",
"cache-manager-redis-store": "^2.0.0",
回答如下:

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论