-
Notifications
You must be signed in to change notification settings - Fork 50
FEATURE: Replace BopGetArgs with operation-specific args classes #1094
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package net.spy.memcached.v2.vo; | ||
|
|
||
| import net.spy.memcached.collection.ElementFlagFilter; | ||
|
|
||
| public class BopRangeGetArgs { | ||
|
|
||
| public static final BopRangeGetArgs DEFAULT | ||
| = new BopRangeGetArgs(ElementFlagFilter.DO_NOT_FILTER, 0, 50, GetOption.NONE); | ||
|
|
||
| private final ElementFlagFilter eFlagFilter; | ||
| private final int offset; | ||
| private final int count; | ||
| private final GetOption option; | ||
|
|
||
| public BopRangeGetArgs(ElementFlagFilter eFlagFilter, int offset, int count, GetOption option) { | ||
| if (offset < 0) { | ||
| throw new IllegalArgumentException("offset cannot be negative"); | ||
| } | ||
|
|
||
| if (count < 1 || count > 50) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 50 이라는 제한이 있어야 하나요?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 고민을 해본 결과 아래와 같이 수정할 수 있을 것 같습니다.
참고로
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 논의 대상이군요.
나중에 bop mget에서도
그리고, DEFAULT 값은 |
||
| throw new IllegalArgumentException("count must be between 1 and 50"); | ||
| } | ||
|
|
||
| if (option == null) { | ||
| throw new IllegalArgumentException("option cannot be null"); | ||
| } | ||
|
|
||
| this.eFlagFilter = eFlagFilter; | ||
| this.offset = offset; | ||
| this.count = count; | ||
| this.option = option; | ||
| } | ||
|
|
||
| public ElementFlagFilter getEFlagFilter() { | ||
| return eFlagFilter; | ||
| } | ||
|
|
||
| public int getOffset() { | ||
| return offset; | ||
| } | ||
|
|
||
| public int getCount() { | ||
| return count; | ||
| } | ||
|
|
||
| public boolean isWithDelete() { | ||
| return option.isWithDelete(); | ||
| } | ||
|
|
||
| public boolean isDropIfEmpty() { | ||
| return option.isDropIfEmpty(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package net.spy.memcached.v2.vo; | ||
|
|
||
| import net.spy.memcached.collection.ElementFlagFilter; | ||
|
|
||
| public class BopSMGetArgs { | ||
|
|
||
| public static final BopSMGetArgs DEFAULT | ||
| = new BopSMGetArgs(ElementFlagFilter.DO_NOT_FILTER, 1000, false); | ||
|
|
||
| private final ElementFlagFilter eFlagFilter; | ||
| private final int count; | ||
| private final boolean unique; | ||
|
|
||
| public BopSMGetArgs(ElementFlagFilter eFlagFilter, int count, boolean unique) { | ||
| if (count < 1 || count > 1000) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1000 값은 MAX_SMGET_COUNT 형태로 상수화하여 사용하는 것은 어떤지?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1000 이라는 값을 SMGet count 제한이라는 의미를 드러낼 수 있어서 상수화 해도 좋을 것 같습니다. 반영하겠습니다. |
||
| throw new IllegalArgumentException("count must be between 1 and 1000"); | ||
| } | ||
|
|
||
| this.eFlagFilter = eFlagFilter; | ||
| this.count = count; | ||
| this.unique = unique; | ||
| } | ||
|
|
||
| public ElementFlagFilter getEFlagFilter() { | ||
| return eFlagFilter; | ||
| } | ||
|
|
||
| public int getCount() { | ||
| return count; | ||
| } | ||
|
|
||
| public boolean isUnique() { | ||
| return unique; | ||
| } | ||
| } | ||
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.
테스트 목적으로만 사용될 것으로 보이며,
테스트 쪽 코드에 두는 것은 어떤지?
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.
BopGetArgs.DEFAULT는 eFlag filter 없이 단순 조회하는 케이스가 많다고 판단하여ElementFlagFilter.DO_NOT_FILTER + GetOption.NONE조합으로 제공했습니다.이번 PR의 목적이
BopGetArgs를 연산별 args로 분리하는 것이다 보니같은 취지로
BopRangeGetArgs.DEFAULT,BopSMGetArgs.DEFAULT도 추가를 한 상태입니다.다만
BopRangeGetArgs와BopSMGetArgs는 단순 옵션뿐 아니라offset,count,unique처럼 조회 결과 범위와 동작에 영향을 주는 값을 포함하여 어색해보이기는 하는데 제거하는 방향이 좋을까요?Uh oh!
There was an error while loading. Please reload this page.
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.
여기도 논의 대상이군요.
각 연산의 semantic에 따라 인자들의 default 값을 정한다면 아래와 같으니, 참고 바랍니다.
지금 다시 생각해 보면, 아래 값을 넘기는 것 자체도 어색하지 않나 생각됩니다.
따라서, 아래와 같이 인자들은 모두 풀어서 표현하고(인자 수가 많지 않음),
필수 인자는 항상 값이 주어져야 하고, 나머지는 Nullable 인자로 생략 시 null을 넘기는 것도
방안이라고 생각합니다. 검토 바랍니다.