Open lukawski opened 2 years ago
Hi @lukawski
Have you tried setting the clearRelatedCache
option in the configuration ?
From the readme
By setting the clearRelatedCache to true, the middleware will inspect the Strapi models before a cache clearing operation to locate models that have relations with the queried model so that their cache is also cleared (this clears the whole cache for the related models). The ispection is performed by looking for direct relations between models and also by doing a deep dive in components, looking for relations to the queried model there too.
Hi @patrixr. Yes, I do have clearRelatedCache
set to true
. I should probably include in in my original question, here is my config
cache: {
type: 'redis',
enabled: true,
clearRelatedCache: true,
populateStrapiMiddleware: true,
models: [
{
model: 'global',
singleType: true,
},
'category',
],
redisConfig: {
host: process.env.REDIS_HOST,
port: process.env.REDIS_PORT,
},
},
And here a the versions of Strapi and cache middleware
I also took a dive into middleware code and I see that getRelatedModels
loops over model attributes to look for related models. I console log in this loop and I can confirm that when I update the entry in categories collection there is no global
attribute relation. I guess that's because of how Strapi creates relations on the global model, since its single type it's one-sided I guess. So we only have information about this relation on the Global
model but not on the Category
.
Hello! Can you try to update strapi-middleware-cache to latest version (2.1.1) ?
Hi @stafyniaksacha, yes, I will, I wanted to wait with it till we have more time on a project but it might be a good idea to do it right now. I will get back to you when I do!
@stafyniaksacha so after the update same behavior occurs. When I do update an entry in categories collection cache for the global model is not cleared.
Hello, thanks for this great package! I noticed that if I have a single type model with
hasMany
relation, updating data in the related model doesn't bust this single model cache.That's how my relation looks like.
I wonder, is there any way to make it work? Or it would require changes in the middleware code itself?