@@ -9,7 +9,7 @@ import { AnalyticsEvents } from 'commandkit/analytics';
99import { randomUUID } from 'node:crypto' ;
1010import ms , { type StringValue } from 'ms' ;
1111import { getCacheProvider } from './cache-plugin' ;
12- import stableHash from 'stable-hash ' ;
12+ import { createHash } from './utils ' ;
1313
1414const cacheContext = new AsyncLocalStorage < CacheContext > ( ) ;
1515const fnStore = new Map <
@@ -28,13 +28,7 @@ const CACHE_FN_ID = `__cache_fn_id_${Date.now()}__${Math.random()}__`;
2828const CACHED_FN_SYMBOL = Symbol ( 'commandkit.cache.sentinel' ) ;
2929
3030// WeakMap to store function metadata without preventing garbage collection
31- const fnMetadata = new WeakMap <
32- GenericFunction ,
33- { id : string ; buildId : string }
34- > ( ) ;
35-
36- // Generate a stable build ID that persists across restarts
37- const BUILD_ID = randomUUID ( ) ;
31+ const fnMetadata = new WeakMap < GenericFunction , string > ( ) ;
3832
3933/**
4034 * Context for managing cache operations within an async scope
@@ -88,20 +82,13 @@ function useCache<R extends any[], F extends AsyncFunction<R>>(
8882 // Get or create function metadata
8983 let metadata = fnMetadata . get ( fn ) ;
9084 if ( ! metadata ) {
91- metadata = {
92- id : randomUUID ( ) ,
93- buildId : BUILD_ID ,
94- } ;
85+ metadata = randomUUID ( ) ;
9586 fnMetadata . set ( fn , metadata ) ;
9687 }
9788
9889 const memo = ( async ( ...args ) => {
9990 const analytics = getCommandKit ( ) ?. analytics ;
100- const keyHash = await stableHash ( {
101- fnId : metadata . id ,
102- buildId : metadata . buildId ,
103- args,
104- } ) ;
91+ const keyHash = createHash ( metadata , args ) ;
10592
10693 const resolvedTTL =
10794 isLocal && params ?. ttl != null
0 commit comments