-
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
INTERNAL: Remove dummy fetch in the get API #334
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 |
---|---|---|
|
@@ -485,6 +485,12 @@ char *memcached_get_by_key(memcached_st *ptr, | |
{ | ||
arcus_server_check_for_update(ptr); | ||
|
||
if (value_length) | ||
*value_length= 0; | ||
|
||
if (flags) | ||
*flags= 0; | ||
|
||
memcached_return_t unused; | ||
if (error == NULL) | ||
error= &unused; | ||
|
@@ -503,11 +509,6 @@ char *memcached_get_by_key(memcached_st *ptr, | |
*error= memcached_last_error(ptr); | ||
} | ||
|
||
if (value_length) | ||
{ | ||
*value_length= 0; | ||
} | ||
|
||
return NULL; | ||
} | ||
|
||
|
@@ -540,20 +541,36 @@ char *memcached_get_by_key(memcached_st *ptr, | |
*error= memcached_last_error(ptr); | ||
} | ||
|
||
if (value_length) | ||
*value_length= 0; | ||
|
||
return NULL; | ||
} | ||
|
||
char *value= memcached_fetch(ptr, NULL, NULL, | ||
value_length, flags, error); | ||
char *value= NULL; | ||
bool is_value_fetched= false; | ||
memcached_result_st *result= &ptr->result; | ||
|
||
while (memcached_fetch_result(ptr, result, error) != NULL) | ||
{ | ||
is_value_fetched= true; | ||
if (value != NULL) | ||
libmemcached_free(ptr, value); | ||
value= memcached_string_take_value(&result->value); | ||
if (value_length) | ||
*value_length= memcached_string_length(&result->value); | ||
if (flags) | ||
*flags= result->item_flags; | ||
} | ||
|
||
assert_msg(ptr->query_id >= query_id +1, "Programmer error, the query_id was not incremented."); | ||
//assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented."); | ||
|
||
/* This is for historical reasons */ | ||
if (*error == MEMCACHED_END) | ||
if (is_value_fetched) | ||
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. is_value_fetched ๋ผ๋ ๋ณ์๊ฐ ํ์ํ๊ฐ์? ์๋์ ๊ฐ์ด ๊ฒ์ฌํ๋ฉด ๋์ง ์๋์? if (value) |
||
{ | ||
*error= 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. success_occurred ๊ฒฝ์ฐ๋ value != NULL ์ํ์
๋๋ค. ๊ทธ๋ฆฌ๊ณ , ์ด๋ฌํ ์ฝ๋๋ 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. value์ ๋น ๋ฌธ์์ด์ ์ ์ฅํ์ ๊ฒฝ์ฐ, ์ฉ์ด๋ฅผ success_occurred์์ is_value_fetched๋ก ๋ณ๊ฒฝํ์ต๋๋ค. 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. @ing-eoking
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. result->value์๋ ๋น ๋ฌธ์์ด์ด ๋ค์ด๊ฐ๋๋ฐ, ์ด๋ฅผ ๋ค์ value์ copyํ์ฌ ๋ฃ๋ ๊ณผ์ ์์ NULL๋ก ๋ณํ๋ฉ๋๋ค. if (not memcached_string_length(string))
return NULL; 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. value == NULL๋ก ํด์ ์ ์ฅํ ์ ์๋์? 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.
๋ถ๊ฐ๋ฅํฉ๋๋ค. ์๋ฒ ์ธก์์๋ value์ NULL ๊ฐ์ ์ ์ฅํ ์ ์์ผ๋ฉฐ, 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. value = NULL, value_length = 0์ผ๋ก ํ์ฌ set ํ๋ฉด ์ด๋ค ์ค๋ฅ๊ฐ ๋ฐ์ํ๋์? 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. value_length๊ฐ 0์ด๋ฏ๋ก ๋น๋ฌธ์์ด์ด ๋ค์ด๊ฐ๊ฒ ๋ฉ๋๋ค. memcached_set(memc, "i", 1, NULL, 0, 0, 0);
|
||
else if (*error == MEMCACHED_END) | ||
{ | ||
*error= MEMCACHED_NOTFOUND; | ||
} | ||
|
||
if (value == NULL) | ||
{ | ||
|
@@ -607,18 +624,6 @@ char *memcached_get_by_key(memcached_st *ptr, | |
return NULL; | ||
} | ||
|
||
size_t dummy_length; | ||
uint32_t dummy_flags; | ||
memcached_return_t dummy_error; | ||
|
||
char *dummy_value= memcached_fetch(ptr, NULL, NULL, | ||
&dummy_length, &dummy_flags, | ||
&dummy_error); | ||
assert_msg(dummy_value == 0, "memcached_fetch() returned additional values beyond the single get it expected"); | ||
assert_msg(dummy_length == 0, "memcached_fetch() returned additional values beyond the single get it expected"); | ||
assert_msg(ptr->query_id >= query_id +1, "Programmer error, the query_id was not incremented."); | ||
//assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented."); | ||
|
||
return value; | ||
} | ||
|
||
|
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.
memcached_fetch_result() != NULL ๊ฒฝ์ฐ๊ฐ 2ํ ์ด์ ๋ฐ์ํ๋ ๊ฒฝ์ฐ๋ ๊ณ ๋ คํ์์ฃ .
This comment was marked as off-topic.
Sorry, something went wrong.
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.
์์ ์ ์ด๋ ๊ฒ ์ฝ๋ฉํธ ํ์ง๋ง, ์ด๋ฌํ ๊ฒฝ์ฐ๊ฐ ๋ฐ์ํ์ง ์๋๋ค๊ณ ๋ณด๋ ๊ฒ์ด ๋ง๊ฒ ์ฃ ?
๋ง์ฝ์ SW ๋ฒ๊ทธ๋ฅผ ๊ณ ๋ คํ๋๋ผ๋ END ์ด์ ์ ๊ฐ์ฅ ๋ง์ง๋ง ๊ฐ์ ๋ฐํํ๋ฉด ๋ ๊ฒ ๊ฐ์ต๋๋ค.
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.
while loop ์์ ์๋ ์ฝ๋๊ฐ ์์ด์ผ ํ์ฃ ?