Skip to content

Commit 74bcc0f

Browse files
committed
just hash whole cache value
1 parent 899967f commit 74bcc0f

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/cache/abstract-assignment-cache.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,8 @@ export function assignmentCacheKeyToString({ subjectKey, flagKey }: AssignmentCa
2626
return getMD5Hash([subjectKey, flagKey].join(';'));
2727
}
2828

29-
export function assignmentCacheValueToString(cacheValue: AssignmentCacheValue): string {
30-
const fieldsToHash: string[] = [];
31-
32-
if ('allocationKey' in cacheValue && 'variationKey' in cacheValue) {
33-
fieldsToHash.push(cacheValue.allocationKey, cacheValue.variationKey);
34-
}
35-
36-
if ('banditKey' in cacheValue && 'actionKey' in cacheValue) {
37-
fieldsToHash.push(cacheValue.banditKey, cacheValue.actionKey);
38-
}
39-
40-
return getMD5Hash(fieldsToHash.join(';'));
29+
export function assignmentCacheValueToString(cacheValue: Record<string, string>): string {
30+
return getMD5Hash(Object.values(cacheValue).join(';'));
4131
}
4232

4333
export interface AsyncMap<K, V> {

0 commit comments

Comments
 (0)