Skip to content

Commit

Permalink
redis queue library version update
Browse files Browse the repository at this point in the history
  • Loading branch information
hkulekci committed Feb 2, 2023
1 parent b754e23 commit a2ce09a
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 1,109 deletions.
9 changes: 6 additions & 3 deletions libraries/database.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var mysql = require('mysql2');
const mysql = require('mysql2');

var pool = mysql.createPool({
const pool = mysql.createPool({
host: process.env.MYSQL_HOST,
user: process.env.MYSQL_USER,
password: process.env.MYSQL_PASS,
Expand All @@ -9,7 +9,10 @@ var pool = mysql.createPool({
debug: process.env.MYSQL_DEBUG == 'true' ? true : false,
connectionLimit: 10,
supportBigNumbers: true,
insecureAuth: true // *** dont use production. ***
insecureAuth: true, // *** dont use production. ***
maxIdle: 10,
idleTimeout: 60000,
queueLimit: 0
});

module.exports = pool;
28 changes: 16 additions & 12 deletions libraries/redis-client.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
var redis = require('redis');
client = redis.createClient({'host': process.env.REDIS_HOST});

await client.connect();
const redis = require('redis');
client = redis.createClient({'url': process.env.REDIS_HOST});

const RedisClient = {
getClient: function() {
if (!client.isOpen) {
client.connect().then()
}
return client;
},

Expand All @@ -26,14 +27,17 @@ const RedisClient = {
}
},

get: function(key, callback) {
client.get(key, function(err, result) {
if (result) {
callback(err, JSON.parse(result));
return;
}
callback(true, {});
});
get: async function(key) {
if (!client.isOpen) {
await client.connect()
}
const value = await client.get(key);

if (value !== null) {
return JSON.parse(value);
}

return null;
},

delete: function() {
Expand Down
Loading

0 comments on commit a2ce09a

Please sign in to comment.