Skip to content

Commit 4f725dd

Browse files
author
Samin Rahman
committed
Removed unused getOldestClientKey from RotatingClientKeyProvider
1 parent e081a78 commit 4f725dd

3 files changed

Lines changed: 0 additions & 61 deletions

File tree

src/main/java/com/uid2/shared/store/IClientKeyProvider.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ public interface IClientKeyProvider extends IAuthorizableProvider {
99
ClientKey getClientKey(String key);
1010
ClientKey getClientKeyFromHash(String hash);
1111
Collection<ClientKey> getAll();
12-
ClientKey getOldestClientKey(int siteId);
1312
}

src/main/java/com/uid2/shared/store/reader/RotatingClientKeyProvider.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@
4444
public class RotatingClientKeyProvider implements IClientKeyProvider, StoreReader<Collection<ClientKey>> {
4545
private final ScopedStoreReader<Collection<ClientKey>> reader;
4646
private final AuthorizableStore<ClientKey> authorizableStore;
47-
private final ConcurrentHashMap<Integer, VersionedValue> oldestClientKeyBySiteIdCache = new ConcurrentHashMap<>();
48-
private volatile long snapshotVersion = 0;
49-
50-
private record VersionedValue(long version, Optional<ClientKey> value) {}
5147

5248
public RotatingClientKeyProvider(DownloadCloudStorage fileStreamProvider, StoreScope scope) {
5349
this.reader = new ScopedStoreReader<>(fileStreamProvider, scope, new ClientParser(), "auth keys");
@@ -73,10 +69,6 @@ public long getVersion(JsonObject metadata) {
7369
public long loadContent(JsonObject metadata) throws Exception {
7470
long version = reader.loadContent(metadata, "client_keys");
7571
authorizableStore.refresh(getAll());
76-
77-
// Versioning to prevent race conditions when reading the oldest client key
78-
oldestClientKeyBySiteIdCache.clear();
79-
snapshotVersion = getVersion(metadata);
8072
return version;
8173
}
8274

@@ -109,21 +101,4 @@ public CloudPath getMetadataPath() {
109101
public IAuthorizable get(String key) {
110102
return getClientKey(key);
111103
}
112-
113-
@Override
114-
public ClientKey getOldestClientKey(int siteId) {
115-
long currentVersion = snapshotVersion;
116-
VersionedValue cached = oldestClientKeyBySiteIdCache.get(siteId);
117-
118-
if (cached != null && cached.version() == currentVersion) {
119-
return cached.value().orElse(null);
120-
}
121-
122-
Optional<ClientKey> computed = this.reader.getSnapshot().stream()
123-
.filter(k -> k.getSiteId() == siteId)
124-
.min(Comparator.comparingLong(ClientKey::getCreated));
125-
126-
oldestClientKeyBySiteIdCache.put(siteId, new VersionedValue(currentVersion, computed));
127-
return computed.orElse(null);
128-
}
129104
}

src/test/java/com/uid2/shared/auth/RotatingClientKeyProviderTest.java

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)