node-redis | A high performance Node.js Redis client | Runtime Evironment library

 by   NodeRedis TypeScript Version: v4.0.0-rc.0 License: MIT

kandi X-RAY | node-redis Summary

kandi X-RAY | node-redis Summary

node-redis is a TypeScript library typically used in Server, Runtime Evironment, Nodejs applications. node-redis has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

A high performance Node.js Redis client.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              node-redis has a medium active ecosystem.
              It has 14162 star(s) with 1510 fork(s). There are 308 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 101 open issues and 981 have been closed. On average issues are closed in 253 days. There are 18 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of node-redis is v4.0.0-rc.0

            kandi-Quality Quality

              node-redis has 0 bugs and 0 code smells.

            kandi-Security Security

              node-redis has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              node-redis code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              node-redis is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              node-redis releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of node-redis
            Get all kandi verified functions for this library.

            node-redis Key Features

            No Key Features are available at this moment for node-redis.

            node-redis Examples and Code Snippets

            Auto-Pipelining
            npmdot img1Lines of Code : 6dot img1no licencesLicense : No License
            copy iconCopy
            client.set('Tm9kZSBSZWRpcw==', 'users:1');
            client.sAdd('users:1:tokens', 'Tm9kZSBSZWRpcw==');
            
            
            await Promise.all([
              client.set('Tm9kZSBSZWRpcw==', 'users:1'),
              client.sAdd('users:1:tokens', 'Tm9kZSBSZWRpcw==')
            ]);
            
              
            Unsupported Redis Commands
            npmdot img2Lines of Code : 3dot img2no licencesLicense : No License
            copy iconCopy
            await client.sendCommand(['SET', 'key', 'value', 'NX']); // 'OK'
            
            await client.sendCommand(['HGETALL', 'key']); // ['key1', 'field1', 'key2', 'field2']
            
              

            Community Discussions

            QUESTION

            Getting "ERR syntax error" on set using node-redis
            Asked 2021-Apr-21 at 12:48

            I am unable to set and get key in redis using node-redis. But set and get works well when using redis-cli. This is my code:

            ...

            ANSWER

            Answered 2021-Apr-21 at 12:48

            Thanks all for suggestion. I posted the question as issue on the repo https://github.com/NodeRedis/node-redis/issues/1599 and got the answer from leibale:

            Source https://stackoverflow.com/questions/67174022

            QUESTION

            Make redis cache expire at certain time everyday
            Asked 2021-Apr-10 at 21:04

            I am using node-redis. I have a cron job that updates my db and I have redis cache that caches the db response.

            The problem I'm having is that my cron job runs everyday at 12am, however I can only set redis cache to expire in x seconds from now. Is there a way to make node-redis cache expire everyday at 12am exactly. Thanks.

            Code:

            ...

            ANSWER

            Answered 2021-Apr-10 at 21:04

            yes, you can use https://redis.io/commands/expireat command, if you use https://www.npmjs.com/package/redis package as redis driver, code will be like this

            Source https://stackoverflow.com/questions/67039128

            QUESTION

            How to configure Node Redis client to throw errors immediately, when connection has failed? [READ DETAILS]
            Asked 2021-Mar-31 at 20:26

            I am using Node Redis with this config:

            ...

            ANSWER

            Answered 2021-Mar-31 at 20:26

            Setting enable_offline_queue to false did the trick. Found lots of similar questions but none mentioned this:

            Nodejs set timeout for Redis requests

            What's the default timeout of ioredis send command for any redis call

            How to set read timeout on node redis client?

            Finally got this solution from here: https://github.com/NodeRedis/node-redis/issues/789#issuecomment-373270272

            Do keep in mind that, with enable_offline_queue set to false, the commands that you issue while there's some connection issue with the server will never be executed.

            Source https://stackoverflow.com/questions/66893022

            QUESTION

            ReplyError: ERR invalid expire time in set - redis - Node.js
            Asked 2020-Dec-08 at 08:20

            I have a Node.js web application which uses redis as session storage. Some requests receive the following ReplyError while trying to save the session:

            ...

            ANSWER

            Answered 2020-Dec-08 at 08:20

            It turned out to be a known issue with manually saving a session in connect-redis. More info can be found at https://github.com/tj/connect-redis/issues/292.

            Source https://stackoverflow.com/questions/65161120

            QUESTION

            Redis Recursion: Maximum callstack size exceeded
            Asked 2020-Oct-15 at 05:31

            I am trying to write a timer for a game. I decided to use Redis and Web Sockets to keep the timer consistent across multiple devices. I have a function that works however when I go to call it recursively with either setTimeout or setInterval I get a "Range Error: Maximum call stack size exceeded". I can not figure out how to bypass this error. Does anyone know if it has to do with the blocking nature of the node-redis publish method? I have attached the code below.

            ...

            ANSWER

            Answered 2020-Oct-15 at 05:31

            You are executing tick() before setting an interval which results in an infinite loop:

            Source https://stackoverflow.com/questions/64358799

            QUESTION

            How do I use HMSET with node promisify
            Asked 2020-Aug-22 at 18:16

            I am using node (TypeScript) and node-redis library. Since I use TypeScript, I also imported @types/redis.

            In addition, I read this article on how to promisify redis methods for TypeScript usage: https://flaviocopes.com/node-promisify/

            My problem is that is that it works for some redis methods (like GET, SET, etc) but it does not work with e.g. HSET or HGETALL.

            If I look into type suggestions, I see the critical methods are actually not methods at all, but rather properties (hset, HSET):

            Why is this so? How can I access those needed methods?

            I guess I am doing something obvious wrong. Any ideas?

            ...

            ANSWER

            Answered 2020-Aug-22 at 18:16

            I took a look at the source code of the typings and it seems that e.g. get is defined as a function:

            Source https://stackoverflow.com/questions/63539317

            QUESTION

            Connecting to managed redis with auth username/password nodejs
            Asked 2020-Aug-18 at 02:21

            Edit: After thinking about the issue, the real question is what is an example of connecting to digitalocean's managed redis with node-redis using tls?

            I'm able to connect just fine with redisinsight GUI client using username / password, but cannot connect with nodejs. It's on the same computer so no firewall issues.

            ...

            ANSWER

            Answered 2020-Aug-16 at 07:36

            The AUTH command, as stated in the docs:

            When ACLs are used, the single argument form of the command, where only the password is specified, assumes that the implicit username is "default".

            So even if you are using Redis 6, where additional users are supported, your authentication for default should work.

            The error you're seeing is the result of a broken connection, e.g. you somehow lost connection with the Redis server. node-redis is dealing with one of two scenarios (or both) - the connection has timed out or the the reconnect attempts have exceeded the maximum number specified in a config. I would double check your connection information and how your redis server is configured.

            I see you are using TLS, you may find this useful: Securing Node Redis

            If you want to authenticate node-redis client with a different user, when using Redis 6, you will have to use send_command, but before you need to remove the current AUTH command, as currently node-redis doesn't support the new command AUTH .

            Source https://stackoverflow.com/questions/63432302

            QUESTION

            Can one single Redis connection serve a thousand concurrent users?
            Asked 2020-Aug-16 at 18:20

            Context: I am building an application that will be accessed concurrently by 1000 users and using Redis as the database. I am using node-redis client. I read that it's recommended to have only one or few connections open from each instance of the application because opening connections is expensive.

            Question: Suppose the client sends a command to Redis. This command is in transit to Redis or being executed (essentially, not completed) when the application needs to send another command. Does the client wait for the first command to be completed or does it fire the second command to Redis right then?

            This is important because if the client waits, the application is not really able to make full use of async and the network calls will become a big bottleneck when commands from a thousand users are trying to access Redis. It's better that the commands are queued up in Redis already instead of having them wait for an earlier command to complete before going through the network.

            Thanks!

            ...

            ANSWER

            Answered 2020-Aug-14 at 21:15

            You can run multiple instances of your node application and then balance the load using Nginx (assuming you're using it). The client won't have to wait and the load will be balanced.

            Use Redis Pub/Sub to create connections.

            Here's documentation for reference.

            Update: Found a detailed step by step explanation here

            Source https://stackoverflow.com/questions/63419992

            QUESTION

            NestJS with node-redis
            Asked 2020-Jul-06 at 19:07

            Wondering if anyone could help me out with this, as I'm new to NestJS.

            I'm trying to use Redis in my existing NestJS service, rather than creating a separate microservice like Nest documents in their examples. When I import redis from node-redis it comes back as undefined.

            token.service.ts

            ...

            ANSWER

            Answered 2020-Jul-06 at 19:07

            You're likely having an issue with the import statement.

            Try replacing

            Source https://stackoverflow.com/questions/62762743

            QUESTION

            Redis punsubscribe not unsubscribing
            Asked 2020-Apr-27 at 16:04

            I have one redis client for pub-sub. I'm using a websocket message handler to dynamically subscribe to a redis channel. The payload of the websocket message contains an ID that I use to create the channel-name. So for example lobby:${lobbyID}:joined. Subscribing to this channel works fine, messages are received when publishing to that channel.

            But the issue that I'm having is that I want to unsubscribe from this channel at one point. My assumption by reading the redis-documentation is that I would use punsubscribe so I can unsubscribe from any channels with the pattern lobby:*:joined, but messages are still received after trying that.

            ...

            ANSWER

            Answered 2020-Apr-27 at 16:04

            I noticed that there are two different types of subscriptions. On channels and patterns. In my question I was subscribing to a channel, and unsubscribing on a pattern, these two are not 'compatible' so this won't work. I used nc to debug this, as redis-cli won't allow additional commands when entering subscribed state.

            Source https://stackoverflow.com/questions/61191421

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install node-redis

            :warning: The new interface is clean and cool, but if you have an existing code base, you'll want to read the migration guide.

            Support

            If you want to run commands and/or use arguments that Node Redis doesn't know about (yet!) use .sendCommand():.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/NodeRedis/node-redis.git

          • CLI

            gh repo clone NodeRedis/node-redis

          • sshUrl

            git@github.com:NodeRedis/node-redis.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link