BewareMyPower commented on PR #21271:
URL: https://github.com/apache/pulsar/pull/21271#issuecomment-1751943721
> As for the getLatestSnapshotAsync method, I don't quite understand its use
case.
It provides a consistency view. For example, let's assume there are two keys
that represents x and y that satisfy `y = x * 2` (just an example). The change
might be:
- x: 0, 1, 3, 7, ...
- y: 0, 2, 6, 14, ...
With `refreshAsync`, you might call:
```java
view.refreshAsync().thenAccept(__ -> { // now, x = 3 and y = 6
int x = view.get("x"); // x = 3
int y = view.get("y"); // y = 14, actually, at the moment, view.get("x")
is 7
// If users want to process x and y here, they might find the difference
is unexpected large
```
With `getLatestSnapshotAsync()` method, you can write:
```java
view.getLatestSnapshotAsync().thenAccept(snapshot -> {
int x = snapshot.get("x"); // x = 3, view.get("x") = 3, view.get("y") = 6
int y = snapshot.get("y"); // y = 6, even if now view.get("y") is 14
});
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]