-
Notifications
You must be signed in to change notification settings - Fork 16
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
FEATURE: Add a mop upsert command #292
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 |
---|---|---|
|
@@ -28,6 +28,7 @@ typedef enum { | |
SOP_DELETE_OP, | ||
SOP_EXIST_OP, | ||
MOP_INSERT_OP, | ||
MOP_UPSERT_OP, | ||
MOP_UPDATE_OP, | ||
MOP_GET_OP, | ||
MOP_DELETE_OP, | ||
|
@@ -65,6 +66,7 @@ static inline const char *coll_op_string(memcached_coll_action_t verb) | |
case SOP_DELETE_OP: return "sop delete "; | ||
case SOP_EXIST_OP: return "sop exist "; | ||
case MOP_INSERT_OP: return "mop insert "; | ||
case MOP_UPSERT_OP: return "mop upsert "; | ||
case MOP_UPDATE_OP: return "mop update "; | ||
case MOP_GET_OP: return "mop get "; | ||
case MOP_DELETE_OP: return "mop delete "; | ||
|
@@ -105,6 +107,7 @@ static inline int coll_op_length(memcached_coll_action_t verb) | |
case SOP_DELETE_OP: return 11; | ||
case SOP_EXIST_OP: return 10; | ||
case MOP_INSERT_OP: return 11; | ||
case MOP_UPSERT_OP: return 11; | ||
case MOP_UPDATE_OP: return 11; | ||
case MOP_GET_OP: return 8; | ||
case MOP_DELETE_OP: return 11; | ||
|
@@ -1291,7 +1294,7 @@ static memcached_return_t do_coll_insert(memcached_st *ptr, | |
{ | ||
/* no sub key */ | ||
} | ||
else if (verb == MOP_INSERT_OP) | ||
else if (verb == MOP_INSERT_OP || verb == MOP_UPSERT_OP) | ||
{ | ||
size_t mkey_length = query->sub_key.mkey.length; | ||
if (mkey_length > MEMCACHED_COLL_MAX_MOP_MKEY_LENG) | ||
|
@@ -1334,7 +1337,8 @@ static memcached_return_t do_coll_insert(memcached_st *ptr, | |
if (attributes) | ||
{ | ||
bool set_overflowaction= verb != SOP_INSERT_OP && | ||
verb != MOP_INSERT_OP | ||
verb != MOP_INSERT_OP && | ||
verb != MOP_UPSERT_OP | ||
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. 아래 위치에 다음과 같은 코드가 있습니다. else if (rc == MEMCACHED_REPLACED && verb == BOP_UPSERT_OP)
{
/* bop upsert returns REPLACED if the same bkey element is replaced. */
rc= MEMCACHED_SUCCESS;
} 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. DOCS 확인 결과, 아래와 같습니다.
mop upsert 또한 일치시키겠습니다. |
||
&& attributes->overflowaction | ||
&& attributes->overflowaction != OVERFLOWACTION_NONE; | ||
|
||
|
@@ -1406,9 +1410,9 @@ static memcached_return_t do_coll_insert(memcached_st *ptr, | |
{ | ||
rc= MEMCACHED_SUCCESS; | ||
} | ||
else if (rc == MEMCACHED_REPLACED && verb == BOP_UPSERT_OP) | ||
else if (rc == MEMCACHED_REPLACED && (verb == BOP_UPSERT_OP || verb == MOP_UPSERT_OP)) | ||
{ | ||
/* bop upsert returns REPLACED if the same bkey element is replaced. */ | ||
/* mop/bop upsert returns REPLACED if the same bkey element is replaced. */ | ||
rc= MEMCACHED_SUCCESS; | ||
} | ||
} | ||
|
@@ -3793,6 +3797,21 @@ memcached_return_t memcached_mop_insert(memcached_st *ptr, | |
&query, NULL, attributes, MOP_INSERT_OP); | ||
} | ||
|
||
memcached_return_t memcached_mop_upsert(memcached_st *ptr, | ||
const char *key, size_t key_length, | ||
const char *mkey, size_t mkey_length, | ||
const char *value, size_t value_length, | ||
memcached_coll_create_attrs_st *attributes) | ||
{ | ||
memcached_coll_query_st query; | ||
memcached_mop_query_init(&query, mkey, mkey_length); | ||
query.value = value; | ||
query.value_length = value_length; | ||
|
||
return do_coll_insert(ptr, key, key_length, | ||
&query, NULL, attributes, MOP_UPSERT_OP); | ||
} | ||
|
||
memcached_return_t memcached_mop_update(memcached_st *ptr, | ||
const char *key, size_t key_length, | ||
const char *mkey, size_t mkey_length, | ||
|
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.
여기만 영문 사용하는 것이 일관성이 없습니다.
java client 쪽과 논의하여 맞추도록 하세요.
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.
java client도 bop의 upsert 만 영문으로 사용되고 있습니다. 영어단어를 그대로 사용해도 괜찮을까요?
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.
bop upsert가 그렇다면, mop upsert도 동일하게 합시다.