Skip to content

Commit

Permalink
Merge branch 'pr/cache-sizes' into pr/getCacheStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Dec 4, 2023
2 parents 147a491 + b2d33d0 commit f09cd6e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
34 changes: 34 additions & 0 deletions .api-reports/api-report-utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ import type { Observer } from 'zen-observable-ts';
import type { OperationDefinitionNode } from 'graphql';
import type { SelectionNode } from 'graphql';
import type { SelectionSetNode } from 'graphql';
import { StrongCache } from '@wry/caches';
import type { Subscriber } from 'zen-observable-ts';
import { Trie } from '@wry/trie';
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
import type { ValueNode } from 'graphql';
import type { VariableDefinitionNode } from 'graphql';
import type { VariableNode } from 'graphql';
import { WeakCache } from '@wry/caches';

// @public (undocumented)
export const addTypenameToDocument: (<TNode extends ASTNode>(doc: TNode) => TNode) & {
Expand Down Expand Up @@ -444,6 +446,24 @@ class CacheGroup {
resetCaching(): void;
}

// @public
interface CacheSizes {
canonicalStringify: number;
documentTransform: number;
fragmentRegistryFindFragmentSpreads: number;
fragmentRegistryLookup: number;
fragmentRegistryTransform: number;
parser: number;
persistedQueryHashes: number;
print: number;
queryManagerTransforms: number;
}

// Warning: (ae-forgotten-export) The symbol "CacheSizes" needs to be exported by the entry point index.d.ts
//
// @public
export const cacheSizes: CacheSizes;

// @public (undocumented)
const enum CacheWriteBehavior {
// (undocumented)
Expand Down Expand Up @@ -483,6 +503,20 @@ export const canUseWeakSet: boolean;
// @public (undocumented)
export function checkDocument(doc: DocumentNode): DocumentNode;

// @public
export class CleanStrongCache<K, V> extends StrongCache<K, V> {
constructor(max: number, dispose?: (value: V) => void);
// (undocumented)
set(key: K, value: V): V;
}

// @public
export class CleanWeakCache<K extends object, V> extends WeakCache<K, V> {
constructor(max: number, dispose?: (value: V) => void);
// (undocumented)
set(key: K, value: V): V;
}

// @public
export function cloneDeep<T>(value: T): T;

Expand Down
2 changes: 1 addition & 1 deletion src/utilities/caching/caches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function schedule(cache: CommonCache<any, any>) {
* already handles cleanup and should remain a `WeakCache`.
*/

export class CleanWeakCache<K extends WeakKey, V> extends WeakCache<K, V> {
export class CleanWeakCache<K extends object, V> extends WeakCache<K, V> {
constructor(max: number, dispose?: (value: V) => void) {
super(max, dispose);
}
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/graphql/DocumentTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { invariant } from "../globals/index.js";
import type { DocumentNode } from "graphql";
import { WeakCache } from "@wry/caches";
import { wrap } from "optimism";
import { cacheSizes } from "../../utilities/index.js";
import { cacheSizes } from "../caching/index.js";

export type DocumentTransformCacheKey = ReadonlyArray<unknown>;

Expand Down

0 comments on commit f09cd6e

Please sign in to comment.