Group cache entries for bulk clearing
masterYou can group cache entries by assigning a value to req.apicacheGroup within your route handler. This allows you to clear an entire collection of cached items at once using apicache.clear(groupName).
import apicache from 'apicache'
let cache = apicache.middleware
app.use(cache('5 minutes'))
// routes are automatically added to index, but may be further added
// to groups for quick deleting of collections
app.get('/api/:collection/:item?', (req, res) => {
req.apicacheGroup = req.params.collection
res.json({ success: true })
})
// To clear the group later:
// apicache.clear('collection_name')