naver / arcus-c-client

ARCUS C client
https://github.com/naver/arcus
Apache License 2.0
12 stars 16 forks source link

FEATURE: Add multi store APIs #293

Closed ing-eoking closed 3 months ago

ing-eoking commented 4 months ago

๐Ÿ”— Related Issue

โŒจ๏ธ What I did

๐Ÿค” Others

ing-eoking commented 4 months ago

ํ™œ์šฉ ์˜ˆ์ œ

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;

}

  - ๊ฒฐ๊ณผ
    - ๋ชจ๋‘ ์„ฑ๊ณตํ•œ ๊ฒฝ์šฐ
key0 : STORED
key1 : STORED
key2 : STORED
key3 : STORED
key4 : STORED
key5 : STORED
key6 : STORED
```
- ์ค‘๊ฐ„์— ์—๋Ÿฌ ๋ฐœ์ƒ(key3์— ๋Œ€ํ•˜์—ฌ TYPE_MISMATCH ์—๋Ÿฌ ๊ฐ•์ œ ๋ฐœ์ƒ)
```
key0 : STORED
key1 : STORED
key2 : STORED
key3 : COLLECTION TYPE MISMATCH
key4 : STORED
key5 : STORED
key6 : STORED
```
jhpark816 commented 4 months ago

@namsic approveํ•œ ์ƒํƒœ์ธ๊ฐ€์š”?

namsic commented 4 months ago

@jhpark816 approve ์ดํ›„ ์ˆ˜์ •์ด ์žˆ์–ด์„œ, ๋‹ค์‹œ ํ™•์ธ ์ค‘์ž…๋‹ˆ๋‹ค.

ing-eoking commented 3 months ago

ํ•ด๋‹น ์ž‘์—…์€ @uhm0311 ์ด ํ•˜๊ณ  ์žˆ์œผ๋ฏ€๋กœ PR ๋‹ซ๊ฒ ์Šต๋‹ˆ๋‹ค.