I have a trouble with redis package. There's in it's docs:
This library is a 1 to 1 mapping of the Redis commands.
But I can not access Redis commands through this lib's client.
I'm creating a client like this:
const client = createClient({
  socket: {
    host: process.env.REDIS_HOST,
    port: +process.env.REDIS_PORT!,
    password: process.env.REDIS_PASSWORD
  }
});
createClient is imported this way: import { createClient } from 'redis'; 
And when I try to call any Redis command on this client, e.g.:
client.rpush('key', 'value');
I get an error:
this.client.rpush is not a function
And console.log(Object.keys(client)); output is:
[
  '_events',
  '_eventsCount',
  '_maxListeners',
  'select',
  'subscribe',
  'pSubscribe',
  'unsubscribe',
  'pUnsubscribe',
  'quit'
]
Am I doing something wrong? And how can I fix it?
As per the Redis Commands section in the README file,
There is built-in support for all of the out-of-the-box Redis commands. They are exposed using the raw Redis command names (HSET, HGETALL, etc.) and a friendlier camel-cased version (hSet, hGetAll, etc.):
So, use the rpush command as client.RPUSH('key', 'value'); or client.rPush('key', 'value');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With