Any way to send api response after the event is fired? · Issue #259 · node-cache/node-cache · GitHub
Skip to content

Any way to send api response after the event is fired? #259

Description

@sudhiryadav

I know this is not an issue and doesn't concern with this library. I am trying to refresh cache from an API like the below method:

function refreshCache(req, res, next) {
    appCache.flushAll();
    res.status(200).send('Cache cleared');
}

The flush event below is called; however I would like to send the response after the tasks are done but no way to find the response object here:

appCache.on("flush", function () {
    reloadCache(); // <-- This is some promise and i want to send response after that.
    log.console.info('App Cache: flushed. Going to reload cache');
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions