The data obtained by nodejs redis is returned by Synchronize.

topic description

nodejs redis gets the data and Synchronize returns

sources of topics and their own ideas

Synchronize returns the data saved by redis

related codes

// 

/**
 * string
 * @param key 
 * @param callBack(err,result)
 */
db.get = function(key, callback){
    client.get(key, function(err,result){
        if (err) {
            console.log(err);
            callback(err,null)
            return;
        }

        callback(null,result);
    });
}
    //
    Redis.set("GetColumnList","",3600,redis.print);
    //
    var data=  Redis.get("GetColumnList",redis.print);
    if (data!=null && data!=undefined && data!="") {
        console.log(data);
        res.send(data);
    }else {
        console.log(data);
        res.send("");
    }

what result do you expect? What is the error message actually seen?

Synchronize returns data

Aug.14,2021

redis acquires content asynchronously, which is usually provided by the callback parameter. You need to obtain the content in the callback. Or directly use async/await to implement

// async + await 
async function test() {
  await Redis.set('something', '');

  const data = await Redis.get('something');

  // 
  console.log(data);
}

refer to koa2

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eab4e6-46d89.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eab4e6-46d89.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?