use keep alive in disk cache and user counter

This commit is contained in:
Ajay
2022-12-05 17:06:00 -05:00
parent d7d5618985
commit cff2325aef
2 changed files with 19 additions and 5 deletions

View File

@@ -1,15 +1,23 @@
import axios, { AxiosError } from "axios";
import { Agent } from "http";
import { config } from "../config";
import { Logger } from "./logger";
const httpAgent = new Agent({ keepAlive: true });
class DiskCache {
async set(key: string, value: unknown): Promise<boolean> {
if (!config.diskCacheURL) return false;
try {
const result = await axios.post(`${config.diskCacheURL}/api/v1/item`, {
key,
value
const result = await axios({
method: "post",
url: `${config.diskCacheURL}/api/v1/item`,
data: {
key,
value
},
httpAgent
});
return result.status === 200;