File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -35,17 +35,23 @@ export class Auth extends BaseAuth {
3535}
3636
3737export class WorkersKVStoreSingle extends WorkersKVStore {
38- private static instance ?: WorkersKVStoreSingle ;
38+ private static instance ?: Map < string , WorkersKVStoreSingle > ;
3939
4040 private constructor ( cacheKey : string , cfKVNamespace : KVNamespace ) {
4141 super ( cacheKey , cfKVNamespace ) ;
4242 }
4343
4444 static getOrInitialize ( cacheKey : string , cfKVNamespace : KVNamespace ) : WorkersKVStoreSingle {
4545 if ( ! WorkersKVStoreSingle . instance ) {
46- WorkersKVStoreSingle . instance = new WorkersKVStoreSingle ( cacheKey , cfKVNamespace ) ;
46+ WorkersKVStoreSingle . instance = new Map < string , WorkersKVStoreSingle > ( ) ;
4747 }
48- return WorkersKVStoreSingle . instance ;
48+ const instance = WorkersKVStoreSingle . instance . get ( cacheKey ) ;
49+ if ( instance ) {
50+ return instance ;
51+ }
52+ const newInstance = new WorkersKVStoreSingle ( cacheKey , cfKVNamespace ) ;
53+ WorkersKVStoreSingle . instance . set ( cacheKey , newInstance ) ;
54+ return newInstance ;
4955 }
5056}
5157
You can’t perform that action at this time.
0 commit comments