Skip to content

Commit 4ef778f

Browse files
author
jianggang
committed
feat: refactor FPUser getKey function
1 parent 858d25b commit 4ef778f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/main/java/com/featureprobe/sdk/server/FPUser.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ public boolean containAttr(String name) {
6060
* @return key
6161
*/
6262
public String getKey() {
63+
if (key == null) {
64+
this.key = String.valueOf(System.nanoTime());
65+
}
6366
return key;
6467
}
6568

src/main/java/com/featureprobe/sdk/server/model/Split.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public Split(List<List<List<Integer>>> distribution) {
3535
}
3636

3737
public HitResult findIndex(FPUser user, String toggleKey) {
38-
String hashKey = user.getKey() != null ? user.getKey() : String.valueOf(System.nanoTime());
39-
user.stableRollout(hashKey);
38+
String hashKey = user.getKey();
4039
if (StringUtils.isNotBlank(bucketBy)) {
4140
if (user.containAttr(bucketBy)) {
4241
hashKey = user.getAttr(bucketBy);

0 commit comments

Comments
 (0)