feat(medusa): Cache modules (#3187)

This commit is contained in:
Frane Polić
2023-03-10 15:09:26 +01:00
committed by GitHub
parent f43f03badb
commit f97b3d7cce
42 changed files with 783 additions and 186 deletions
@@ -18,7 +18,7 @@ describe("ContentfulService", () => {
return Promise.resolve(undefined)
}),
}
const redisClient = {
const cacheService = {
get: async (id) => {
// const key = `${id}_ignore_${side}`
if (id === `ignored_ignore_contentful`) {
@@ -44,7 +44,7 @@ describe("ContentfulService", () => {
{
regionService,
productService,
redisClient,
cacheService,
productVariantService,
eventBusService,
},
@@ -9,7 +9,7 @@ class ContentfulService extends BaseService {
{
regionService,
productService,
redisClient,
cacheService,
productVariantService,
eventBusService,
},
@@ -31,24 +31,23 @@ class ContentfulService extends BaseService {
accessToken: options.access_token,
})
this.redis_ = redisClient
this.cacheService_ = cacheService
this.capab_ = {}
}
async addIgnore_(id, side) {
const key = `${id}_ignore_${side}`
return await this.redis_.set(
return await this.cacheService_.set(
key,
1,
"EX",
this.options_.ignore_threshold || IGNORE_THRESHOLD
)
}
async shouldIgnore_(id, side) {
const key = `${id}_ignore_${side}`
return await this.redis_.get(key)
return await this.cacheService_.get(key)
}
async getContentfulEnvironment_() {