
com.launchdarkly.sdk.server.ServerSideEventContextDeduplicator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of launchdarkly-java-server-sdk Show documentation
Show all versions of launchdarkly-java-server-sdk Show documentation
Official LaunchDarkly SDK for Java
package com.launchdarkly.sdk.server;
import com.launchdarkly.sdk.LDContext;
import com.launchdarkly.sdk.internal.events.EventContextDeduplicator;
import java.time.Duration;
final class ServerSideEventContextDeduplicator implements EventContextDeduplicator {
private final SimpleLRUCache contextKeys;
private final Duration flushInterval;
public ServerSideEventContextDeduplicator(
int capacity,
Duration flushInterval
) {
this.contextKeys = new SimpleLRUCache<>(capacity);
this.flushInterval = flushInterval;
}
@Override
public Long getFlushInterval() {
return flushInterval.toMillis();
}
@Override
public boolean processContext(LDContext context) {
String key = context.getFullyQualifiedKey();
if (key == null || key.isEmpty()) {
return false;
}
String previousValue = contextKeys.put(key, key);
return previousValue == null;
}
@Override
public void flush() {
contextKeys.clear();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy