@@ -136,17 +136,17 @@ END
136
136
@io << ident ident " let cacheKey: string | null = null, decodedKey: string | null = null, cacheExpirationSeconds: number | null = null, cacheVersion: number | null = null;\n "
137
137
@io << ident ident " if (cacheConfig.#{ op.pretty_name } ) {\n "
138
138
@io << ident ident ident " try {\n "
139
- @io << ident ident ident ident " const {key, expirationSeconds, version: cacheVersion} = await cacheConfig.#{ op.pretty_name } (#{ ([" ctx" ] + op.args.map(& .name)).join(" , " ) } );\n "
139
+ @io << ident ident ident ident " const {key: cacheKey , expirationSeconds: cacheExpirationSeconds , version: cacheVersion} = await cacheConfig.#{ op.pretty_name } (#{ ([" ctx" ] + op.args.map(& .name)).join(" , " ) } );\n "
140
140
@io << ident ident ident ident " if (!key) throw \"\" ;\n "
141
- @io << ident ident ident ident " cacheKey = crypto.createHash(\" sha256\" ).update(JSON.stringify(key )+ \" -#{ op.pretty_name } \" ).digest(\" hex\" ).substr(0, 100); decodedKey = JSON.stringify(key); cacheExpirationSeconds = expirationSeconds ;\n "
142
- @io << ident ident ident ident " const cache = await hook.getCache(cacheKey , cacheVersion);console.log(JSON.stringify(cache));\n "
141
+ @io << ident ident ident ident " const cacheKeyEncoded = crypto.createHash(\" sha256\" ).update(JSON.stringify(cacheKey )+ \" -#{ op.pretty_name } \" ).digest(\" hex\" ).substr(0, 100); decodedKey = JSON.stringify(cacheKey) ;\n "
142
+ @io << ident ident ident ident " const cache = await hook.getCache(cacheKeyEncoded , cacheVersion);console.log(JSON.stringify(cache));\n "
143
143
@io << ident ident ident ident " if (cache && (!cache.expirationDate || cache.expirationDate > new Date())) return cache.ret;\n "
144
144
@io << ident ident ident " } catch(e) {console.log(JSON.stringify(e));}\n "
145
145
@io << ident ident " }\n "
146
146
@io << ident ident " const ret = await fn.#{ op.pretty_name } (#{ ([" ctx" ] + op.args.map(& .name)).join(" , " ) } );\n "
147
147
@io << ident ident op.return_type.typescript_check_decoded(" ret" , " \" #{ op.pretty_name } .ret\" " )
148
148
@io << ident ident " const encodedRet = " + op.return_type.typescript_encode(" ret" ) + " ;\n "
149
- @io << ident ident " if (cacheKey !== null && cacheVersion !== null) hook.setCache(cacheKey , cacheExpirationSeconds ? new Date(new Date().getTime() + (cacheExpirationSeconds * 1000)) : null, cacheVersion, decodedKey!, \" #{ op.pretty_name } \" , encodedRet);\n "
149
+ @io << ident ident " if (cacheKeyEncoded !== null && cacheVersion !== null) hook.setCache(cacheKeyEncoded , cacheExpirationSeconds ? new Date(new Date().getTime() + (cacheExpirationSeconds * 1000)) : null, cacheVersion, decodedKey!, \" #{ op.pretty_name } \" , encodedRet);\n "
150
150
@io << ident ident " return encodedRet"
151
151
@io << ident " },\n "
152
152
end
0 commit comments