mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 20:08:01 +01:00
Add support for clearing accounts from Redis asynchronously
This commit is contained in:
committed by
Jon Chambers
parent
8c93368b20
commit
d17c7aaba6
@@ -23,6 +23,7 @@ import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.Collections;
|
||||
@@ -987,4 +988,19 @@ public class AccountsManager {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> redisDeleteAsync(final Account account) {
|
||||
@SuppressWarnings("resource") final Timer.Context timerContext = redisDeleteTimer.time();
|
||||
|
||||
final List<String> keysToDelete = new ArrayList<>(4);
|
||||
keysToDelete.add(getAccountMapKey(account.getNumber()));
|
||||
keysToDelete.add(getAccountMapKey(account.getPhoneNumberIdentifier().toString()));
|
||||
keysToDelete.add(getAccountEntityKey(account.getUuid()));
|
||||
|
||||
account.getUsernameHash().ifPresent(usernameHash -> keysToDelete.add(getUsernameHashAccountMapKey(usernameHash)));
|
||||
|
||||
return cacheCluster.withCluster(connection -> connection.async().del(keysToDelete.toArray(new String[0])))
|
||||
.toCompletableFuture()
|
||||
.thenRun(timerContext::close);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user