@@ -9,7 +9,7 @@ import { AnalyticsEvents } from 'commandkit/analytics';
9
9
import { randomUUID } from 'node:crypto' ;
10
10
import ms , { type StringValue } from 'ms' ;
11
11
import { getCacheProvider } from './cache-plugin' ;
12
- import stableHash from 'stable-hash ' ;
12
+ import { createHash } from './utils ' ;
13
13
14
14
const cacheContext = new AsyncLocalStorage < CacheContext > ( ) ;
15
15
const fnStore = new Map <
@@ -28,13 +28,7 @@ const CACHE_FN_ID = `__cache_fn_id_${Date.now()}__${Math.random()}__`;
28
28
const CACHED_FN_SYMBOL = Symbol ( 'commandkit.cache.sentinel' ) ;
29
29
30
30
// 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 > ( ) ;
38
32
39
33
/**
40
34
* Context for managing cache operations within an async scope
@@ -88,20 +82,13 @@ function useCache<R extends any[], F extends AsyncFunction<R>>(
88
82
// Get or create function metadata
89
83
let metadata = fnMetadata . get ( fn ) ;
90
84
if ( ! metadata ) {
91
- metadata = {
92
- id : randomUUID ( ) ,
93
- buildId : BUILD_ID ,
94
- } ;
85
+ metadata = randomUUID ( ) ;
95
86
fnMetadata . set ( fn , metadata ) ;
96
87
}
97
88
98
89
const memo = ( async ( ...args ) => {
99
90
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 ) ;
105
92
106
93
const resolvedTTL =
107
94
isLocal && params ?. ttl != null
0 commit comments