Please has anyone ever used NodeJS
+ Redis
+ MySQL
The goal is to have NodeJS fetch data from Redis and only reach MySQL if data not found, also update MySQL
back with the data.
Then how can i run relational request from Redis knowing its a NoSQL
in-memory DB
I have read that Redis is better than Memcached
and it seems to be faster so I wanted to try it out but it seems all tutorial i can lay my hands on are just PHP
based.
Currently I use NodeJs + MySQL as below (example) :
var d = new Date();
var date = d.getFullYear() + '-' + paddnum(Math.round(d.getMonth() + 1)) + '-' + paddnum(d.getDate()) + ' ' + paddnum(d.getHours()) + ':' + paddnum(d.getMinutes()) + ':' + paddnum(d.getSeconds());
var query = `INSERT INTO comments (COMMENT, POSTID)
VALUES ('{"author":"` + data.userid + `", "comment": "` + data.comment + `", "time":"` + date + `"}', ` + data.postid + `)
ON DUPLICATE KEY UPDATE
COMMENT = CONCAT(COMMENT, ',{"author":"` + data.userid + `", "comment": "` + data.comment + `", "time":"` + date + `"}'),
POSTID = ` + data.postid;
//console.log(query);
connection.query(query,
function(err, results) {
if (err) {
return err;
}
return results;
}
);