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

Issue resetting cache group #93

Closed
franky-continu opened this issue Jul 11, 2017 · 5 comments
Closed

Issue resetting cache group #93

franky-continu opened this issue Jul 11, 2017 · 5 comments

Comments

@franky-continu
Copy link

franky-continu commented Jul 11, 2017

I have a list of categories. methods get categories find etc are cached and update and create have clear statements.

var cache_manager = require('../../../modules/cache-manager');
var apicache = cache_manager.apicache;
var apigroup = 'categories';

exports.find = function (req, res, next) {
  req.apicacheGroup = apigroup;
  categoriesManager.find(req.companyId, req.url)
  .then(function(categories) {
    res.json(200, categories);
    return next();
  }).catch(function(error) {
    handleError(error, req, res, next);
  });
};

exports.update = function (req, res, next) {
  apicache.clear(apigroup);
  categoriesManager.update(req.companyId, req.params.id, req.body, req.url)
  .then(function(category) {
    res.json(200, category);
    return next();
  }).catch(function(error) {
    handleError(error, req, res, next);
  });
};

I can verify the clearing done in the logs:


2017-07-11T14:45:31.994614622Z �[39m�[36m[apicache]�[0m clearing group "categories"
2017-07-11T14:45:31.994637984Z �[36m[apicache]�[0m clearing cached entry for "/learn/v3/categories?department=$ne..."
2017-07-11T14:45:31.994733375Z �[36m[apicache]�[0m clearing cached entry for.."/learn/v3/categories.....

etc etc

But then I still see in the inspector Network tab --> Column (Size) (from disk):

screen shot 2017-07-11 at 8 41 50 am

How can I instruct brower/angular/etc to clear it's cache?

@franky-continu
Copy link
Author

I'm caching API calls that go to the DB so that API calls will go to REDIS instead

But if the browser won't call the API for the amount of cache-control:max-age=7200 for example, then any updates to the DB which I call reset group so that the cache and redis db get updated with our DB will not make it to the browser because the browser won't ask or request it in the first place

@SnidelyWhiplash
Copy link

@franky-continu It sounds like you're hitting the same problem as in #74. A recent update allows for a {headers: { 'cache-control': 'no-cache' } } option to disable it.

@franky-continu
Copy link
Author

Sounds fantastic. Thanks @SnidelyWhiplash ;

Another thing that happens is that we have a cluster of apis, so I've forked to see if I can save the key indexes and groups (specially) in the same REDIS.

Otherwise Node-1 saves a call and then the same user requests on Node-2 instead of Node-1.

Or worse Node-1 Saves and Node-2 updates and the drop of the group doesn't hit Node-1 because it is locally save.

@SnidelyWhiplash
Copy link

@franky-continu Yeah it doesn't make sense that the index is stored in memory. There's discussion around that in #78 and a PR in #82 that somewhat addresses it.

@kwhitley
Copy link
Owner

Agreed that this is an issue, and will be addressed in future redis store implementation. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants