@@ -65,7 +65,7 @@ export abstract class CachedResource<V> {
6565 if ( duration < this . expirationInMilli ) {
6666 logger . info ( `cache hit, duration(%sms) is less than expiration(%sms)` , duration , this . expirationInMilli )
6767 // release the lock
68- await this . updateCache ( cachedValue , {
68+ await this . updateResourceCache ( cachedValue , {
6969 ...resource ,
7070 locked : false ,
7171 } )
@@ -97,7 +97,7 @@ export abstract class CachedResource<V> {
9797 result : latest ,
9898 }
9999 logger . info ( `doen loading the latest of resource(%s), updating resource cache` , this . key )
100- await this . updateCache ( cachedValue , r )
100+ await this . updateResourceCache ( cachedValue , r )
101101 return latest
102102 } catch ( e ) {
103103 logger . info (
@@ -115,7 +115,7 @@ export abstract class CachedResource<V> {
115115 const cachedValue = this . readCacheOrDefault ( )
116116
117117 if ( ! cachedValue . resource . locked ) {
118- await this . updateCache ( cachedValue , {
118+ await this . updateResourceCache ( cachedValue , {
119119 ...cachedValue . resource ,
120120 locked : true ,
121121 } )
@@ -144,11 +144,13 @@ export abstract class CachedResource<V> {
144144 } )
145145 }
146146
147- private async updateCache ( cache : GlobalStateSchema < any > | undefined , resource : Resource < any > ) {
148- await globals . globalState . update ( this . key , {
147+ private async updateResourceCache ( cache : GlobalStateSchema < any > | undefined , resource : Resource < any > ) {
148+ const toUpdate : GlobalStateSchema < V > = {
149149 ...( cache ? cache : this . readCacheOrDefault ( ) ) ,
150150 resource : resource ,
151- } )
151+ }
152+
153+ await globals . globalState . update ( this . key , toUpdate )
152154 }
153155
154156 private readCacheOrDefault ( ) : GlobalStateSchema < V > {
0 commit comments