NestJs 缓存管理器问题

编程入门 行业动态 更新时间:2024-10-05 09:28:01

NestJs 缓存<a href=https://www.elefans.com/category/jswz/34/1771330.html style=管理器问题"/>

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",
回答如下:

更多推荐

NestJs 缓存管理器问题

本文发布于:2024-05-30 20:13:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1770877.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:管理器   缓存   NestJs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!