-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flush with wildcard #20
Comments
@etx currently the flush behaviour will depend on the engine, and is something that might need a little more work here. For example the memory engine flush just deletes everything without namespacing as seen here. It would be nice to allow some sort of namespacing with it, but I think would be hard to agree on a format for keys etc. What do you think? The Redis engine is different it will get all keys for a given namespace string and delete them as seen here - there was a reason I did it this specific way but I can't recall it now. It looks like this would achieve what you're asking, right? As a general overview, the flush function exposed by So, with the above fix and a Redis engine would your issue be resolved? |
Also, I think we'd need to update the For example, if we take this code: const getExpeditiousCache = require('express-expeditious');
const express = require('express');
const cache = getExpeditiousCache({
namespace: 'stories',
defaultTtl: '1 minute'
});
const app = express();
app.use(cache);
app.get('/stories/:category', (req, res, next) => {
stories.find({ category: req.params.category }).then(list => res.json(list))
})
app.post('/stories', bodyParser.json(), (req, res, next) => {
stories.replaceAll(req.body).then(result => res.json(result))
cache.flush() // flush all stories
})
app.post('/stories/:category', bodyParser.json(), (req, res, next) => {
stories.updateCategory(req.params.category, req.body).then(result => res.json(result))
cache.flush(req.params.category) // flush all stories in specific category
}) We'd like to flush "stories:*" for |
Yep, exactly! My application is doing basically this, but it listens to updates on the sections from a DB and when something changes it rebuilds the Express Router and calculates the namespace by concatenating 'section' and the name of the section from the DB. But changes to global data would require the cache be purged. Beside completely flushing the cache I can't come up with any other way, and the cache holds pages outside of the sections system and images (now that you so quickly patched that up! :) Just wanted to see if maybe the module had some functionality I wasn't seeing in the docs. |
Does this module have any way to flush the keys using a wildcard?
I'm caching a number of different named sections of a site using namespaces. It's easy to flush a particular section when it is updated in the db, as I know the section namespace. But I would like to flush all sections when a global piece of data has been modified. All the section namespaces start with 'section' so ideally I could flush('section*', callback) but it seems like wildcards do not work.
The text was updated successfully, but these errors were encountered: