Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

let me know how to delete or update cache for the model #96

Open
borusbillion opened this issue Aug 3, 2022 · 0 comments
Open

let me know how to delete or update cache for the model #96

borusbillion opened this issue Aug 3, 2022 · 0 comments

Comments

@borusbillion
Copy link

borusbillion commented Aug 3, 2022

The cache doesn't return the updated data.
I used the default memory cache and following is my cache config in/config/middleware.js
cache: {
enabled: true,
enableEtagSupport: true,
enableXCacheHeaders: true,
withKoaContext: true,
withStrapiMiddleware: true,
clearRelatedCache: true,
maxAge: 3.154e10,
models: [
{
model: 'sqore-posts',
hitpass: false,
singleType: true,
routes: ['/sqore-posts/:slug', '/sqore-posts'],
},
],
},

After updating the content, updated data is not from API and only old cache data when calling /sqore-posts/:slug.

So I tried to clear or update the cache of model "sqore-posts" in the sqore-posts model.
but I don't know how to clear or update the cache.
I used this code in /models/sqore-posts.js.

afterUpdate: async (entry) => {
    console.log('---------------sqore-posts afterUpdate')
    const cacheConf = await strapi.middleware.cache.getCacheConfig('sqore-posts')
    await strapi.middleware.cache.clearCache(cacheConf)
},

I am looking for your help.
Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant