Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.
This repository was 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

Description

@borusbillion

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions