@graphql-eslint/eslint-plugin
Version:
GraphQL plugin for ESLint
30 lines (29 loc) • 710 B
JavaScript
import "./chunk-BMTV3EA2.js";
import debugFactory from "debug";
const log = debugFactory("graphql-eslint:ModuleCache");
class ModuleCache {
constructor() {
this.map = /* @__PURE__ */ new Map();
}
set(cacheKey, result) {
this.map.set(cacheKey, { lastSeen: process.hrtime(), result });
log("setting entry for", cacheKey);
}
get(cacheKey, settings = {
lifetime: 10
/* seconds */
}) {
const value = this.map.get(cacheKey);
if (!value) {
log("cache miss for", cacheKey);
return;
}
const { lastSeen, result } = value;
if (process.env.NODE || process.hrtime(lastSeen)[0] < settings.lifetime) {
return result;
}
}
}
export {
ModuleCache
};