We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 799ab5d commit a10e902Copy full SHA for a10e902
Sources/CMAB/CmabService.swift
@@ -59,11 +59,9 @@ class DefaultCmabService: CmabService {
59
60
private func getLockIndex(userId: String, ruleId: String) -> Int {
61
let combinedKey = userId + ruleId
62
- let hashValue = combinedKey.hashValue
63
- // Take absolute value to ensure positive number
64
- let positiveHash = abs(hashValue)
65
- // Use modulo to map to lock array index [0, NUM_LOCKS-1]
66
- return positiveHash % Self.NUM_LOCKS
+ let hashValue = MurmurHash3.hash32(key: combinedKey)
+ let lockIndex = Int(hashValue) % Self.NUM_LOCKS
+ return lockIndex
67
}
68
69
func getDecision(config: ProjectConfig,
0 commit comments