idealley / feathers-hooks-rediscache

Set of caching hooks and routes for feathersjs.
MIT License
38 stars 12 forks source link

Unknown command with /cache/clear with client.flushall() #55

Closed jamesvillarrubia closed 5 years ago

jamesvillarrubia commented 6 years ago

Steps to reproduce

Submitting GET request to /cache/clear

Expected behavior

Cache Clears

Actual behavior

Response is correct, but when monitoring the CLI, a redis error is thrown:

{ ReplyError: ERR unknown command `flushall`, with args beginning with: 
    at new Command 
    ... 
   command: 'FLUSHALL', code: 'ERR' }

Proposed solution

Utilize the new FlushAll Async construction:

router.get('/clear', (req, res) => {
    client.flushall()
      res.status(HTTP_OK).json({
        message: 'Cache cleared',
        status: HTTP_OK
      });
  }); // clear a unique route

becomes

router.get('/clear', (req, res) => {
    client.flushall('ASYNC', () => {
      res.status(HTTP_OK).json({
        message: 'Cache cleared',
        status: HTTP_OK
      });
    });
  });