*Add cache bypass support for simple query

This commit is contained in:
Derrick Hammer 2022-12-04 06:36:18 -05:00
parent 6429bd513c
commit 8c2f857c55
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 14 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import { RpcQueryOptions } from "../types.js";
import { clearTimeout, setTimeout } from "timers"; import { clearTimeout, setTimeout } from "timers";
import b4a from "b4a"; import b4a from "b4a";
import { import {
hashQuery,
isPromise, isPromise,
validateResponse, validateResponse,
validateTimestampedResponse, validateTimestampedResponse,
@ -51,6 +52,19 @@ export default class SimpleRpcQuery extends RpcQueryBase {
const rpc = new RPC(socket); const rpc = new RPC(socket);
if (this._query.bypassCache) {
delete this._query.bypassCache;
await this.queryRpc(rpc, {
module: "rpc",
method: "clear_cached_item",
data: hashQuery(this._query),
});
}
if ("bypassCache" in this._query) {
delete this._query.bypassCache;
}
try { try {
await this.queryRpc(rpc, this._query); await this.queryRpc(rpc, this._query);
} catch (e: any) { } catch (e: any) {