Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
nestjs:如何在typeorm中删除带有前缀的redis缓存_Nestjs_Typeorm_Redis Cache - Fatal编程技术网

nestjs:如何在typeorm中删除带有前缀的redis缓存

nestjs:如何在typeorm中删除带有前缀的redis缓存,nestjs,typeorm,redis-cache,Nestjs,Typeorm,Redis Cache,我有一个带有create、list和update方法的服务类来修改实体 我在列表方法中设置了redis缓存,缓存键是list\u cache\u 1,list\u cache\u 2,… 我的问题是,如何删除create或update方法中的所有相关缓存,如 this.connection.queryResultCache.remove([`list_cache:*`]); 通过QueryBuilder设置“缓存id”时: const users = await connection

我有一个带有
create、list
update
方法的服务类来修改实体

我在列表方法中设置了redis缓存,缓存键是
list\u cache\u 1,list\u cache\u 2,…

我的问题是,如何删除
create
update
方法中的所有相关缓存,如

this.connection.queryResultCache.remove([`list_cache:*`]);
通过QueryBuilder设置“缓存id”时:

const users = await connection
    .createQueryBuilder(User, "user")
    .where("user.isAdmin = :isAdmin", { isAdmin: true })
    .cache("list_cache_1", 25000)
    .getMany();
或使用存储库:

const users = await connection
    .getRepository(User)
    .find({
        where: { isAdmin: true },
        cache: {
            id: "list_cache_1",
            milliseconds: 25000
        }
    });
然后,获取连接对象并按如下所示移除

import { getConnection } from "typeorm";

const connection = getConnection();
await connection.queryResultCache.remove([`list_cache_1`]);
但是,我不知道有什么类型化方法可以使用通配符删除列表缓存