@go-mailer/jarvis 10.2.0 → 10.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -19,6 +19,20 @@ const HTTPCacheManager = () => {
|
|
|
19
19
|
next();
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
const clearCacheByResource = async (tenant_id, cache_resource) => {
|
|
23
|
+
const repo = await RedisClient.register_schema(HTTPCache);
|
|
24
|
+
const cached_records = await repo
|
|
25
|
+
.search()
|
|
26
|
+
.where("tenant_id")
|
|
27
|
+
.equals(Number(tenant_id))
|
|
28
|
+
.where("resource")
|
|
29
|
+
.equals(cache_resource)
|
|
30
|
+
.returnAll();
|
|
31
|
+
for (const cached_record of cached_records) {
|
|
32
|
+
await repo.remove(cached_record[EntityId]);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
22
36
|
const handleRequest = async (request, response, next) => {
|
|
23
37
|
const { tenant_id, cache_key } = request;
|
|
24
38
|
const repo = await RedisClient.register_schema(HTTPCache);
|
|
@@ -82,7 +96,7 @@ const HTTPCacheManager = () => {
|
|
|
82
96
|
next();
|
|
83
97
|
};
|
|
84
98
|
|
|
85
|
-
return { clearCache, handleRequest, save, setup };
|
|
99
|
+
return { clearCache, clearCacheByResource, handleRequest, save, setup };
|
|
86
100
|
};
|
|
87
101
|
|
|
88
102
|
module.exports = { HTTPCacheManager };
|