Redis synchronization operation

Source: Internet
Author: User
Tags redis server

Asynchronous operations are cumbersome. Difficult to control. The following is a synchronized library Bluebird. The usage is simple. Look at you and you'll know.

Const REDIS = require (' Redis ');

Const BLUEBIRD = require (' Bluebird ');
Bluebird.promisifyall (Redis. Redisclient.prototype);
Bluebird.promisifyall (Redis. Multi.prototype);

Let rds_port= 6379; let Rds_host= "127.0.0.1"; let Rds_pwd= ""; let Rds_opts= Rds_pwd? {auth_pass:rds_pwd}: "";varClient =redis.createclient (Rds_port, Rds_host, rds_opts);

Async Test () {
Let res = await client.keysasync ("*");
Console.log (RES);
}client.on (' Connect ',function() {Console.log (' Successful connection '); //---------------Core Usage----------------------------------- //------------------Client[cmd] (param, CB)-----------------Test ();})//You can also use this method to enter a password//Client.auth (rds_pwd, function () {//Console.log ("Verified by");// })//This event is triggered when the connection to the Redis server is successful, indicating that the command is ready to be received and that the client command will be present in the queue before the event is triggered, and then called sequentially when everything is ready .Client.on (' Ready ',function() {Console.log (' Ready ');}) Client.on (' Error ',function(Err) {Console.log (' ErrorEvent-' + client.host + ': ' + client.port + '-' +err);})

Redis synchronization operation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.