deleteRedisByID
This commit is contained in:
parent
2c26007f2d
commit
22af14721d
1 changed files with 15 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import HttpStatus from "../interfaces/http-status";
|
import HttpStatus from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
import { promisify } from "util";
|
||||||
|
|
||||||
class Extension {
|
class Extension {
|
||||||
public static ConvertToDateTime(value: any) {
|
public static ConvertToDateTime(value: any) {
|
||||||
|
|
@ -296,6 +297,20 @@ class Extension {
|
||||||
years += plusYear - subtractYear;
|
years += plusYear - subtractYear;
|
||||||
return `${years} ปี ${months} เดือน ${days} วัน`;
|
return `${years} ปี ${months} เดือน ${days} วัน`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static deleteRedisByID(type: string, id: string) {
|
||||||
|
const redis = require("redis");
|
||||||
|
const REDIS_HOST = process.env.REDIS_HOST;
|
||||||
|
const REDIS_PORT = process.env.REDIS_PORT;
|
||||||
|
const redisClient = redis.createClient({
|
||||||
|
host: REDIS_HOST,
|
||||||
|
port: REDIS_PORT,
|
||||||
|
});
|
||||||
|
const delAsync = promisify(redisClient.del).bind(redisClient);
|
||||||
|
const deleteKey = delAsync(type + id);
|
||||||
|
console.log(`Deleted ${deleteKey} keys.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Extension;
|
export default Extension;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue