-
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 multi store APIs #293
Conversation
ํ์ฉ ์์
#include "config.hpp"
#include <iostream>
#include <map>
#include "libmemcached/memcached.h"
using namespace std;
#define MAX_NUMBER 7
memcached_st *mc;
bool mc_init() {
mc = memcached_create(NULL);
if (mc == NULL) return false;
//if (MEMCACHED_SUCCESS != memcached_server_add(mc, "127.0.0.1", 54321))
if (MEMCACHED_SUCCESS != arcus_connect(mc, "127.0.0.1:2181", "test"))
return true;
return false;
}
int main(int argc, char **argv) {
if (mc_init()) return -1;
uint32_t flags= 10;
vector< pair<string, string> > kv;
vector<const char *> keys, values;
vector<size_t> keys_length, values_length;
for (int i = 0; i < MAX_NUMBER; i++)
kv.push_back(make_pair("key" + to_string(i), to_string(i)));
for (int i = 0; i < MAX_NUMBER; i++) {
keys.push_back(kv[i].first.c_str());
keys_length.push_back(kv[i].first.length());
values.push_back(kv[i].second.c_str());
values_length.push_back(kv[i].second.length());
}
vector<memcached_return_t> results(MAX_NUMBER);
memcached_set_bulk(mc, (char **)(&keys[0]), (size_t *)(&keys_length[0]), MAX_NUMBER,
(char **)(&values[0]), (size_t *)(&values_length[0]), NULL, flags,
(memcached_return_t *)(&results[0]));
for (int i = 0; i < MAX_NUMBER; i++)
cout << string(keys[i]) << " : " << memcached_strerror(mc, results[i]) << endl;
return 0;
}
|
a07ebb7
to
e49850d
Compare
a2f9657
to
2442aac
Compare
9e7a03a
to
36ef96b
Compare
c295951
to
873cdfe
Compare
7bd4c60
to
e9ccc39
Compare
f6287ed
to
08ceedb
Compare
9ec1610
to
6eabe16
Compare
else if (verb == CAS_OP and cas[i] == 0) | ||
{ | ||
results[i] = MEMCACHED_PROTOCOL_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.
์ด ์กฐ๊ฑด๋ฌธ์ด ์์ผ๋ฉด ์ด๋ป๊ฒ ๋์ํ๊ฒ ๋๋์?
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.
C-Client ๋ด๋ถ์ ์ผ๋ก cas๊ฐ 0์ธ ๊ฒฝ์ฐ cas๋ฅผ ์ ์ธํ๊ณ ๋ณด๋ด๊ฒ ๋ฉ๋๋ค.
๊ทธ๋ฌ๋ฏ๋ก ์๋ฒ๋ก ์๋์ ๊ฐ์ด ๋ณด๋ด๊ฒ ๋๋ค๊ณ ์๊ฐํ์๋ฉด ๋ ๊ฒ ๊ฐ์ต๋๋ค.
cas i 0 0 1
1
์ด ๊ฒฝ์ฐ ์๋ฒ๋ ERROR no matching command
๋ฐํํ๊ฒ ๋๋ฉฐ,
PROTOCOL_ERROR
์ดํ reconnect๋ก ์ธํ CONNECTION_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.
cas ๊ฐ ๊ฒ์ฌ๋ ์๋ ํจ์์์ ์ํํฉ์๋ค.
- memcached_cas()
- memcached_cas_bulk()
@namsic approveํ ์ํ์ธ๊ฐ์? |
@jhpark816 approve ์ดํ ์์ ์ด ์์ด์, ๋ค์ ํ์ธ ์ค์ ๋๋ค. |
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 memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, | ||
memcached_literal_param("value (length) list is null")); | ||
} | ||
if (verb == CAS_OP and not 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.
{
๋ฌธ์๋ ๋ค์ ๋ผ์ธ์์ ์์
else if (verb == CAS_OP and cas[i] == 0) | ||
{ | ||
results[i] = MEMCACHED_PROTOCOL_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.
cas ๊ฐ ๊ฒ์ฌ๋ ์๋ ํจ์์์ ์ํํฉ์๋ค.
- memcached_cas()
- memcached_cas_bulk()
return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, | ||
memcached_literal_param("result is 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.
์ด ์์น์์ memcached_key_test() ์ํํ๋ ๊ฒ์ด ๋ง์ ๊ฒ์ ๋๋ค.
@@ -605,3 +700,92 @@ memcached_return_t memcached_cas_by_key(memcached_st *ptr, | |||
return rc; | |||
} | |||
|
|||
memcached_return_t memcached_set_bulk(memcached_st *ptr, | |||
const char * const *keys, const size_t *key_length, | |||
size_t number_of_keys, |
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.
number_of_keys
๋ณด๋ค๋ keys ์ธ์ ์์ bulk_count
๋๋ ๊ฒ์ด ๋ง์ง ์๋ ์ง ?
expirations ? expirations[i] : 0, flags, | ||
cas ? cas[i] : 0, verb); | ||
} | ||
} |
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_send_bulk_ascii()
ํจ์๋ฅผ ๋ณ๋๋ก ๋๋ ๋ฐฉ์๋ ๊ฒํ ํด ๋ณด์๋์?
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_send_ascii
์ response ๋ถ๋ถ์ ์ ์ธํ ๋ง์ ๋ก์ง์ด ์ผ์นํ๊ฒ ๋ฉ๋๋ค.
(Validation ๊ฒ์ฌ, ๋ช
๋ น์ด ๋ฒกํฐ ๊ตฌ์ฑ)
๊ทธ๋์ ์๋ก ๊ตฌ์ฑํ๋ ๊ฒ๋ณด๋ค๋ memcached_send_ascii
๋ฅผ ํ์ฉํ๋ ๋ฐฉ์์ด ๋ซ๋ค๊ณ ์๊ฐํ์ต๋๋ค.
ํด๋น ์์ ์ @uhm0311 ์ด ํ๊ณ ์์ผ๋ฏ๋ก PR ๋ซ๊ฒ ์ต๋๋ค. |
๐ Related Issue
โจ๏ธ What I did
set
,add
,replace
,append
,prepend
,cas
memcached_send_bulk
๋ฅผ ์ถ๊ฐํฉ๋๋ค.๐ค Others