Skip to content

Commit

Permalink
Switch cache policy
Browse files Browse the repository at this point in the history
Switched cache policy to 1h for users and 1 minute for other items
  • Loading branch information
MalikWhitten67 authored Jun 22, 2024
1 parent 275428f commit c5fabc5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/controllers/CrudManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default class CrudManager {
this.Cache.setCache(data.collection, data.cacheKey, d, 3600)
setTimeout(()=>{
this.Cache.clear(data.collection, data.cacheKey)
}, 3600000)
}, data.collection === 'users' ? 3600000 : 60000) // 1 hour for users, 1 minute for others
return {error: false, message: 'success', key: data.key, data: d, session: data.session}
}

Expand Down Expand Up @@ -275,6 +275,9 @@ export default class CrudManager {
if(cache.exists(collection, cacheKey)){
cache.clear(collection, cacheKey)
}
if(collection === 'users' && cache.exists('users', `posts-${id}`)){
cache.clear('users', `posts-${id}`)
}
for (let i in data.data) {
if (data.data[i].isFile && data.data[i].file) {
let files = handleFiles(data.data[i].file);
Expand Down Expand Up @@ -359,7 +362,7 @@ export default class CrudManager {
this.Cache.setCache(collection, cacheKey, d, 3600)
setTimeout(()=>{
this.Cache.clear(collection, cacheKey)
}, 3600000)
}, collection === 'users' ? 3600000 : 60000) // 1 hour for users, 1 minute for others
return {error: false, message: 'success', key: key, data: d, session: session}
}
}
Expand Down

0 comments on commit c5fabc5

Please sign in to comment.