Add support for clearing accounts from Redis asynchronously
This commit is contained in:
parent
8c93368b20
commit
d17c7aaba6
|
@ -23,6 +23,7 @@ import java.io.IOException;
|
||||||
import java.io.UncheckedIOException;
|
import java.io.UncheckedIOException;
|
||||||
import java.time.Clock;
|
import java.time.Clock;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.Collections;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue