Skip to content
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

Cachekey Tagging #110

Open
krazyjakee opened this issue Jul 31, 2018 · 0 comments
Open

Cachekey Tagging #110

krazyjakee opened this issue Jul 31, 2018 · 0 comments
Labels
enhancement v2.0.0 Road to version 2

Comments

@krazyjakee
Copy link
Collaborator

Feature suggestion: A "tagging" mechanism which gives you the ability to "tag" cache keys and mass invalidate. For example, if I had a movie website and each movie had an overview, review and trailer page, I could del the movie tag like { movie: 1322 } and it would invalidate all 3 caches.

I believe this functionality is part of redis under the SADD and SMEMBER commands. My knowledge of redis is quite limitted.

Proposed router setup:

app.get('/index.html',
  cache.route({ tag: { movie: 1322 }  }),
  function (req, res)  { ... });

From inside the action:

function (req, res, next) {
    res.express_redis_cache_tag = { movie: 1322 };
    next();
    }

Using cache.get:

cache.get({ movie: 1322 }, function (error, entries) {}); // Note object, not string.

Finally cache.del:

cache.del({ movie: 1322 }, callback); // Deletes all associated keys
@krazyjakee krazyjakee added enhancement v2.0.0 Road to version 2 labels Aug 10, 2018
krazyjakee added a commit that referenced this issue Aug 10, 2018
rawpixel-vincent pushed a commit to rawpixel-vincent/express-redis-cache that referenced this issue Jul 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement v2.0.0 Road to version 2
Projects
None yet
Development

No branches or pull requests

1 participant