update proxycheck cache even on withoutCache request
This commit is contained in:
parent
a2147eef8c
commit
8f91b3c241
|
@ -70,6 +70,7 @@ async function withoutCache(f, ip) {
|
|||
throw new Error('Proxycheck request did not return yet');
|
||||
}
|
||||
}
|
||||
cacheAllowed(ipKey, status);
|
||||
whoisRet = await whois(ip);
|
||||
} finally {
|
||||
await saveIPInfo(ipKey, whoisRet || {}, status, pcheck);
|
||||
|
@ -108,11 +109,8 @@ async function withCache(f, ip) {
|
|||
if (checking.indexOf(ipKey) === -1) {
|
||||
checking.push(ipKey);
|
||||
withoutCache(f, ip)
|
||||
.then((result) => {
|
||||
cacheAllowed(ipKey, result);
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error('Error %s', error.message || error);
|
||||
logger.error('Error %s', error.message);
|
||||
})
|
||||
.finally(() => {
|
||||
const pos = checking.indexOf(ipKey);
|
||||
|
|
|
@ -8,9 +8,9 @@ import client from './client';
|
|||
const PREFIX = 'isal:';
|
||||
const CACHE_DURATION = 14 * 24 * 3600;
|
||||
|
||||
export function cacheAllowed(ip, allowed) {
|
||||
export function cacheAllowed(ip, status) {
|
||||
const key = `${PREFIX}:${ip}`;
|
||||
return client.set(key, allowed.status, {
|
||||
return client.set(key, status, {
|
||||
EX: CACHE_DURATION,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user