-
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
DOC: Modify examples for the set document #321
Conversation
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.
๋ฆฌ๋ทฐ ์๋ฃ
docs/05-set-API.md
Outdated
return -1; | ||
} | ||
|
||
if (piped_rc == MEMCACHED_ALL_NOT_EXIST) { |
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.
์ด๊ฒ failure์ ํด๋น๋๋์?
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.
๋ฆฌ๋ทฐ ์๋ฃ
docs/05-set-API.md
Outdated
// ์กฐํ ๊ฒฐ๊ณผ๋ฅผ ์ญ์ ํ๋ค. | ||
memcached_coll_result_free(result); | ||
const char *key= "set:a_key"; | ||
size_t count= 1; |
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.
์ด ๊ฐ์ 0์ผ๋ก ํ๋ฉด ์ ์ฒด element ์กฐํ์ธ ๊ฒ์ด์ฃ ?
์ ์ฒด element ์กฐํ๊ฐ ๋ง๋ค๋ฉด, 0์ผ๋ก ์ค์ ํฉ์๋ค.
๊ทธ๋ฆฌ๊ณ , memcached_sop_get์ count ์ธ์ ์ค๋ช
์ ๋ณด๊ฐํด ์ฃผ์ธ์.
key ์ธ์๋ ์ถ๊ฐํด ์ฃผ์๊ณ ์.
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.
๋ฆฌ๋ทฐ ์๋ฃ
for (size_t i=0; i<number_of_values; i++) { | ||
if (results[i] != MEMCACHED_EXIST && results[i] != MEMCACHED_NOT_EXIST) { | ||
fprintf(stderr, "Failed to memcached_sop_piped_exist: %s : %s %d(%s)\n", | ||
key, values[i], results[i], memcached_strerror(memc, results[i])); |
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.
์ด ๊ฒฝ์ฐ์ results[i] ๊ฐ์ผ๋ก ์ด๋ค ๊ฐ์ด ์๋์?
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.
์๋ฌ์ ํด๋นํ๋ ๊ฐ์ด ๋ชจ๋ ๋ค์ด๊ฐ ์ ์์ต๋๋ค.
(ex. CONNECTION_FAILURE, SERVER_ERROR ๋ฑ๋ฑ)
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.
PIPE_ERROR ๊ฐ์ ๊ฒฝ์ฐ์๋
ํญ์ number_of_values ๊ฐ์ result๊ฐ ๋ด๊ธฐ๋์?
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.
java client ์์์์๋
get ํ๊ธฐ ์ ์ insert ํ๋ ์ฝ๋๊ฐ ์๋ ์ง๋ฅผ ํ์ธํ๊ณ ์๋ ค์ฃผ์ธ์.
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.
PIPE_ERROR ๊ฐ์ ๊ฒฝ์ฐ์๋
ํญ์ number_of_values ๊ฐ์ result๊ฐ ๋ด๊ธฐ๋์?
๋ค ํญ์ number_of_values ๊ฐฏ์๋งํผ result๊ฐ ๋ด๊ธฐ๋ฉฐ, ๋ง์ฝ PIPE_ERROR๋ก ์ธํ์ฌ ์ํ๋์ง ์์ ์ผ๋ถ๋ MEMCACHED_MAXIMUM_RETURN
์ผ๋ก ์ฑ์์ง๋๋ค.
์์ ์๋ฌ ์๋ต๋ ์ฌ ์ ๋ฆฌํด ์ฃผ์๊ณ ์.
์์ ํ์ต๋๋ค. ๋ํ ๋ฌธ์์์ MEMCACHED_SOME_SUCCESS
, MEMCACHED_ALL_FAILURE
๋ด์ฉ์ ์ถ๊ฐํ์ต๋๋ค.
java client ์์์์๋
get ํ๊ธฐ ์ ์ insert ํ๋ ์ฝ๋๊ฐ ์๋ ์ง๋ฅผ ํ์ธํ๊ณ ์๋ ค์ฃผ์ธ์.
์์ต๋๋ค.
String key = "Sample:Set";
int count = 10;
boolean withDelete = false;
boolean dropIfEmpty = false;
CollectionFuture<Set<Object>> future = null;
try {
future = client.asyncSopGet(key, count, withDelete, dropIfEmpty); // (1)
} catch (IllegalStateException e) {
// handle exception
}
if (future == null)
return;
try {
Set<Object> result = future.get(1000L, TimeUnit.MILLISECONDS); // (2)
System.out.println(result);
System.out.println(future.getOperationStatus().getResponse()); // (3)
} catch (TimeoutException e) {
future.cancel(true);
} catch (InterruptedException e) {
future.cancel(true);
} catch (ExecutionException e) {
future.cancel(true);
}
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.
๋ฆฌ๋ทฐ ์๋ฃ
for (size_t i=0; i<number_of_values; i++) { | ||
if (results[i] != MEMCACHED_EXIST && results[i] != MEMCACHED_NOT_EXIST) { | ||
fprintf(stderr, "Failed to memcached_sop_piped_exist: %s : %s %d(%s)\n", | ||
key, values[i], results[i], memcached_strerror(memc, results[i])); |
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.
PIPE_ERROR ๊ฐ์ ๊ฒฝ์ฐ์๋
ํญ์ number_of_values ๊ฐ์ result๊ฐ ๋ด๊ธฐ๋์?
for (size_t i=0; i<number_of_values; i++) { | ||
if (results[i] != MEMCACHED_EXIST && results[i] != MEMCACHED_NOT_EXIST) { | ||
fprintf(stderr, "Failed to memcached_sop_piped_exist: %s : %s %d(%s)\n", | ||
key, values[i], results[i], memcached_strerror(memc, results[i])); |
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.
์์ ์๋ฌ ์๋ต๋ ์ฌ ์ ๋ฆฌํด ์ฃผ์๊ณ ์.
bool drop_if_empty = false; | ||
memcached_coll_result_st result; | ||
memcached_return_t rc; | ||
|
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.
result create
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.
result create;
do {
if (fail) {
break;
}
} while(0);
result free;
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.
์์ ๋์์ต๋๋ค. (list๋ ๋ค์ PR๋ก ์์ ํ๊ฒ ์ต๋๋ค.)
result์ ์ผ๋ถ ๊ฐ์ ๋ํด์๋ง malloc์ด ์ฑ๊ณตํ๋ ๊ฒฝ์ฐ๊ฐ ์กด์ฌํฉ๋๋ค.
(์: values ๊ณต๊ฐ์ ์์ฑํ๋ ๋์ค ์ผ๋ถ๋ ์ฑ๊ณตํ๊ณ ์ผ๋ถ๋ ์คํจํ๋ ๊ฒฝ์ฐ, ์ด ๊ฒฝ์ฐ์๋ ๋ณ๋์ ํธ๋ค๋ง ์์ด ๋ฐ๋ก ์๋ฌ๋ฅผ ๋ฐํํฉ๋๋ค.)
for (size_t i=0; i<number_of_values; i++) { | ||
if (results[i] != MEMCACHED_EXIST && results[i] != MEMCACHED_NOT_EXIST) { | ||
fprintf(stderr, "Failed to memcached_sop_piped_exist: %s : %s %d(%s)\n", | ||
key, values[i], results[i], memcached_strerror(memc, results[i])); |
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 ์์์์๋
get ํ๊ธฐ ์ ์ insert ํ๋ ์ฝ๋๊ฐ ์๋ ์ง๋ฅผ ํ์ธํ๊ณ ์๋ ค์ฃผ์ธ์.
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.
์์ ๋์์ต๋๋ค.
bool drop_if_empty = false; | ||
memcached_coll_result_st result; | ||
memcached_return_t rc; | ||
|
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.
์์ ๋์์ต๋๋ค. (list๋ ๋ค์ PR๋ก ์์ ํ๊ฒ ์ต๋๋ค.)
result์ ์ผ๋ถ ๊ฐ์ ๋ํด์๋ง malloc์ด ์ฑ๊ณตํ๋ ๊ฒฝ์ฐ๊ฐ ์กด์ฌํฉ๋๋ค.
(์: values ๊ณต๊ฐ์ ์์ฑํ๋ ๋์ค ์ผ๋ถ๋ ์ฑ๊ณตํ๊ณ ์ผ๋ถ๋ ์คํจํ๋ ๊ฒฝ์ฐ, ์ด ๊ฒฝ์ฐ์๋ ๋ณ๋์ ํธ๋ค๋ง ์์ด ๋ฐ๋ก ์๋ฌ๋ฅผ ๋ฐํํฉ๋๋ค.)
for (size_t i=0; i<number_of_values; i++) { | ||
if (results[i] != MEMCACHED_EXIST && results[i] != MEMCACHED_NOT_EXIST) { | ||
fprintf(stderr, "Failed to memcached_sop_piped_exist: %s : %s %d(%s)\n", | ||
key, values[i], results[i], memcached_strerror(memc, results[i])); |
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.
PIPE_ERROR ๊ฐ์ ๊ฒฝ์ฐ์๋
ํญ์ number_of_values ๊ฐ์ result๊ฐ ๋ด๊ธฐ๋์?
๋ค ํญ์ number_of_values ๊ฐฏ์๋งํผ result๊ฐ ๋ด๊ธฐ๋ฉฐ, ๋ง์ฝ PIPE_ERROR๋ก ์ธํ์ฌ ์ํ๋์ง ์์ ์ผ๋ถ๋ MEMCACHED_MAXIMUM_RETURN
์ผ๋ก ์ฑ์์ง๋๋ค.
์์ ์๋ฌ ์๋ต๋ ์ฌ ์ ๋ฆฌํด ์ฃผ์๊ณ ์.
์์ ํ์ต๋๋ค. ๋ํ ๋ฌธ์์์ MEMCACHED_SOME_SUCCESS
, MEMCACHED_ALL_FAILURE
๋ด์ฉ์ ์ถ๊ฐํ์ต๋๋ค.
java client ์์์์๋
get ํ๊ธฐ ์ ์ insert ํ๋ ์ฝ๋๊ฐ ์๋ ์ง๋ฅผ ํ์ธํ๊ณ ์๋ ค์ฃผ์ธ์.
์์ต๋๋ค.
String key = "Sample:Set";
int count = 10;
boolean withDelete = false;
boolean dropIfEmpty = false;
CollectionFuture<Set<Object>> future = null;
try {
future = client.asyncSopGet(key, count, withDelete, dropIfEmpty); // (1)
} catch (IllegalStateException e) {
// handle exception
}
if (future == null)
return;
try {
Set<Object> result = future.get(1000L, TimeUnit.MILLISECONDS); // (2)
System.out.println(result);
System.out.println(future.getOperationStatus().getResponse()); // (3)
} catch (TimeoutException e) {
future.cancel(true);
} catch (InterruptedException e) {
future.cancel(true);
} catch (ExecutionException e) {
future.cancel(true);
}
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.
๋ฆฌ๋ทฐ ์๋ฃ
docs/05-set-API.md
Outdated
// ์กฐํ ๊ฒฐ๊ณผ๋ฅผ ์ญ์ ํ๋ค. | ||
memcached_coll_result_free(result); | ||
memcached_coll_result_free(&result); | ||
return 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.
return_value ๋ณ์๋ฅผ ๋์ง ์๊ณ , ์๋์ ๊ฐ์ด ์ฒ๋ฆฌํ์์ฃ .
return (rc == MEMCACHED_SUCCESS) ? 0 : -1;
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.
์์ ๋์์ต๋๋ค.
docs/05-set-API.md
Outdated
const char* value= memcached_coll_result_get_value(&result, i); | ||
fprintf(stdout, "memcached_sop_get: %s : %s\n", key, value); | ||
} | ||
} while(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.
while(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.
์์ ๋์์ต๋๋ค.
docs/05-set-API.md
Outdated
// ์กฐํ ๊ฒฐ๊ณผ๋ฅผ ์ญ์ ํ๋ค. | ||
memcached_coll_result_free(result); | ||
memcached_coll_result_free(&result); | ||
return 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.
์์ ๋์์ต๋๋ค.
๐ Related Issue
โจ๏ธ What I did