RedisEasy work with Node.js at server. It provides
the list of API commands:
set initiate the data for a variableadd update the data for a variableget get data from a variabledel delete data from a variablecount get number of elements of a variable clear clear data of a variableexpire set expiration time for a variablesql perform the SQL string for a variable (database)RedisEasy is available at RedisEasy repository, folder
"Final_v1.x.x/Programs/dist/server"
var Redis = require('./server/rediseasy.min');
const redis = new Redis(); // default connect to 127.0.0.1:6379, db: 0, bMem: 1
// let redis = new Redis({"host":"192.168.1.1", "port":"6380", "db": 1, "bMem": 0});
// in-memory => "bMem": 1
// in file => "bMem": 0
// "db" has value from 0 - 15 (specify the Redis database)
// For more information about input params, please read the documents at Redis repo (Documents folder)
let data = {
variable: "listA",
value: "some-value"
}
// set, get add, del, expire, count, clear & sql commands
redis.set(data, function(err, res){
if(err){
console.log("ERROR: ", err.message);
} else {
console.log("Result: ", res.result);
}
redis.close(); // close the current connection
});
// Promise style
redis.set(data)
.then(res => console.log("Result: ", res.result))
.catch(err => console.log("ERROR: ", err.message));
.finally(()=> redis.close());
For more example about the syntax, see the RedisEasy examples section in the left side menu.
RedisEasy-client supports the set, add, get, del, count and clear commands.
RedisEasy-client usage:
const REClient = require('./client/rediseasy.min');
let params = {
name: "test",
bMem: 1,
targetDomain: ""
}
const client = new REClient(params);
let data = {
variable: "listA",
value: "some-value"
}
// Callback style
client.set(data, function(err, res){
if(err){
console.log("ERROR: ", err.message);
} else {
console.log("Result: ", res.result);
}
});
// Promise style
client.set(data)
.then(res => console.log("Result: ", res.result))
.catch(err => console.log("ERROR: ", err.message));
.finally(()=> redis.close());
For more information, please refer the RedisEasy-client documents in Redis repository.