key = "hello", path = "world.hi", db.get("hello") --> {world: {hi: "value"}}
});
//keyPathing should be set to false, if you want to do "key.hello" as a key
// following events are optional
client
.on("cacheReady", () => {
console.log("DATABASECACHECLIENT ready and connected");
})
.on("cacheError", (error) => {
console.error("DATABASECACHECLIENT error, ERROR:\n", error, "\n---\n");
})
.on("cacheClose", (reason) => {
console.log("DATABASECACHECLIENT closed, REASON?:\n", reason, "\n---\n");
})
.on("cacheMessage", (message) => {
console.log("message", message);
})
.on("cacheRequest", async (request, response, client) => {
console.log("REQUEST", request);
});
// example usage
async function yourProgram(){
await client.set("hi", "bye").then(console.log).catch(console.error);
await client.get("hi").then(console.log).catch(console.error);
await client.set("array", []).then(console.log).catch(console.error);
await client.push("array", "element").then(console.log).catch(console.error);
await client.push("array", "element2").then(console.log).catch(console.error);
await client.size().then(console.log).catch(console.error);
await client.get("array").then(console.log).catch(console.error);
await client.all().then(console.log).catch(console.error);
}
yourProgram();">
const { remoteCacheClient } = require("remote-sqlite-database");
const client = new remoteCacheClient({
username: "db_cache",
password: "db_cache",
host: "localhost",
port: 5000,
tls: true,
keyPathing: true, // true|false ... enables if the key contains a "." that it's splitted to a path, e.g.: "hello.world.hi" --> key = "hello", path = "world.hi", db.get("hello") --> {world: {hi: "value"}}
});
//keyPathing should be set to false, if you want to do "key.hello" as a key
// following events are optional
client
.on("cacheReady", () => {
console.log("DATABASECACHECLIENT ready and connected");
})
.on("cacheError", (error) => {
console.error("DATABASECACHECLIENT error, ERROR:\n", error, "\n---\n");
})
.on("cacheClose", (reason) => {
console.log("DATABASECACHECLIENT closed, REASON?:\n", reason, "\n---\n");
})
.on("cacheMessage", (message) => {
console.log("message", message);
})
.on("cacheRequest", async (request, response, client) => {
console.log("REQUEST", request);
});
// example usage
async function yourProgram(){
await client.set("hi", "bye").then(console.log).catch(console.error);
await client.get("hi").then(console.log).catch(console.error);
await client.set("array", []).then(console.log).catch(console.error);
await client.push("array", "element").then(console.log).catch(console.error);
await client.push("array", "element2").then(console.log).catch(console.error);
await client.size().then(console.log).catch(console.error);
await client.get("array").then(console.log).catch(console.error);
await client.all().then(console.log).catch(console.error);
}
yourProgram();