






















1-import { createDedupeCache, resolveDedupeNonNegativeInteger } from "../infra/dedupe.js";
1+import { createDedupeCache } from "../infra/dedupe.js";
2+import { resolveNonNegativeIntegerOption } from "../infra/numeric-options.js";
23import type { FileLockOptions } from "./file-lock.js";
34import { withFileLock } from "./file-lock.js";
45import { readJsonFileWithFallback, writeJsonFileAtomically } from "./json-store.js";
@@ -148,9 +149,9 @@ function isRecentTimestamp(seenAt: number | undefined, ttlMs: number, now: numbe
148149149150/** Create a dedupe helper that combines in-memory fast checks with a lock-protected disk store. */
150151export function createPersistentDedupe(options: PersistentDedupeOptions): PersistentDedupe {
151-const ttlMs = resolveDedupeNonNegativeInteger(options.ttlMs, 0);
152-const memoryMaxSize = resolveDedupeNonNegativeInteger(options.memoryMaxSize, 0);
153-const fileMaxEntries = Math.max(1, resolveDedupeNonNegativeInteger(options.fileMaxEntries, 1));
152+const ttlMs = resolveNonNegativeIntegerOption(options.ttlMs, 0);
153+const memoryMaxSize = resolveNonNegativeIntegerOption(options.memoryMaxSize, 0);
154+const fileMaxEntries = Math.max(1, resolveNonNegativeIntegerOption(options.fileMaxEntries, 1));
154155const lockOptions = mergeLockOptions(options.lockOptions);
155156const memory = createDedupeCache({ ttlMs, maxSize: memoryMaxSize });
156157const inflight = new Map<string, Promise<boolean>>();
@@ -324,15 +325,15 @@ function createReleasedClaimError(scopedKey: string): Error {
324325325326/** Create a claim/commit/release dedupe guard backed by memory and optional persistent storage. */
326327export function createClaimableDedupe(options: ClaimableDedupeOptions): ClaimableDedupe {
327-const ttlMs = resolveDedupeNonNegativeInteger(options.ttlMs, 0);
328-const memoryMaxSize = resolveDedupeNonNegativeInteger(options.memoryMaxSize, 0);
328+const ttlMs = resolveNonNegativeIntegerOption(options.ttlMs, 0);
329+const memoryMaxSize = resolveNonNegativeIntegerOption(options.memoryMaxSize, 0);
329330const memory = createDedupeCache({ ttlMs, maxSize: memoryMaxSize });
330331const persistent =
331332options.resolveFilePath != null
332333 ? createPersistentDedupe({
333334 ttlMs,
334335 memoryMaxSize,
335-fileMaxEntries: Math.max(1, resolveDedupeNonNegativeInteger(options.fileMaxEntries, 1)),
336+fileMaxEntries: Math.max(1, resolveNonNegativeIntegerOption(options.fileMaxEntries, 1)),
336337resolveFilePath: options.resolveFilePath,
337338lockOptions: options.lockOptions,
338339onDiskError: options.onDiskError,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。