Skip to content

Commit 2f92ff4

Browse files
committed
use xxh3 in backend-shared package
1 parent 5038860 commit 2f92ff4

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

packages/cubejs-backend-shared/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"typescript": "~5.2.2"
3636
},
3737
"dependencies": {
38+
"@node-rs/xxhash": "^1.7.6",
3839
"@oclif/color": "^0.1.2",
3940
"bytes": "^3.1.2",
4041
"cli-progress": "^3.9.0",

packages/cubejs-backend-shared/src/promises.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint-disable arrow-body-style,no-restricted-syntax */
2-
import crypto from 'crypto';
3-
2+
import { xxh3 } from '@node-rs/xxhash';
43
import { Optional } from './type-helpers';
54

65
export type PromiseLock = {
@@ -273,9 +272,7 @@ export const asyncDebounce = <Ret, Arguments>(
273272
const cache = new Map<string, Promise<Ret>>();
274273

275274
return async (...args: Arguments[]) => {
276-
const key = crypto.createHash('md5')
277-
.update(args.map((v) => JSON.stringify(v)).join(','))
278-
.digest('hex');
275+
const key = xxh3.xxh64(args.map((v) => JSON.stringify(v)).join(',')).toString(16);
279276

280277
if (cache.has(key)) {
281278
return <Promise<Ret>>cache.get(key);

0 commit comments

Comments
 (0)