Skip to content

Commit

Permalink
addressing review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed May 9, 2024
1 parent 8990db6 commit 648eefc
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/plugins/expressions/common/execution/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,11 @@ export class Execution<
input: unknown,
args: Record<string, unknown>
): Observable<UnwrapReturnType<Fn['fn']>> {
let hash: string | undefined;

return of(input).pipe(
map((currentInput) => this.cast(currentInput, fn.inputTypes)),
map((normalizedInput) => {
switchMap((normalizedInput) => {
let hash: string | undefined;

if (fn.allowCache && this.context.allowCache) {
hash = calculateObjectHash([
fn.name,
Expand All @@ -479,9 +479,7 @@ export class Execution<
this.context.getSearchContext(),
]);
}
return normalizedInput;
}),
switchMap((normalizedInput) => {

if (hash && this.functionCache.has(hash)) {
const cached = this.functionCache.get(hash);
if (cached && Date.now() - cached.time < this.cacheTimeout) {
Expand Down

0 comments on commit 648eefc

Please sign in to comment.