-
Notifications
You must be signed in to change notification settings - Fork 192
DATACOUCH-1041 - Add withCas() method to RemoveById. #1051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add withCas() method to RemoveById.
6cbc63f
to
cf820ce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me overall, but I think we can get rid of the boxing for less gc
interface ExecutableRemoveById extends RemoveByIdWithDurability {} | ||
interface RemoveByIdWithCas extends RemoveByIdWithDurability { | ||
|
||
RemoveByIdWithDurability withCas(Long cas); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this a boxed long and not an unboxed long
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that null can have different semantics than zero.
@@ -45,17 +46,19 @@ public ExecutableRemoveById removeById() { | |||
private final PersistTo persistTo; | |||
private final ReplicateTo replicateTo; | |||
private final DurabilityLevel durabilityLevel; | |||
private final Long cas; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, could this be a primitive long?
interface ReactiveRemoveById extends RemoveByIdWithDurability {} | ||
interface RemoveByIdWithCas extends RemoveByIdWithDurability { | ||
|
||
RemoveByIdWithDurability withCas(Long cas); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above w.r.t boxing
@@ -81,28 +83,36 @@ private RemoveOptions buildRemoveOptions() { | |||
} else if (durabilityLevel != DurabilityLevel.NONE) { | |||
options.durability(durabilityLevel); | |||
} | |||
if (cas != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the boxing and null, but it could just check if != 0 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comes from a comment made by Mark Paluch on another change-set regarding Expiry(I think). It's not quite the same for CAS, but I wanted to keep the same pattern/semantics - that null means "never been set/not specified", while an Object (including an object with value 0) means that it has been set.
In other words - something like this - That if it was set to non-Zero by an annotation, then there was no way to override (unset) it with the fluent call because it was already non-Duration.zero and the fluent call had to set it to Duration.zero, but Duration.zero (from the fluent call or otherwise) is treated as "never been set", so the value from the annotation would not be overridden. So null would have the semantics of "never been set", and Duration.zero has the semantics of "been set to zero".
Add withCas() method to RemoveById as the cas in the entity cannot be used as the entity is not pass in the API. The other option was to add methods like one(T entity) and all(Collection), but those class with one(String id) and all(Collection ids).