-
Notifications
You must be signed in to change notification settings - Fork 19
/
multi.cpp
55 lines (47 loc) · 1.25 KB
/
multi.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <redispp.h>
#include <stdio.h>
#include <string>
#ifdef _WIN32
#include <Windows.h>
#endif
using namespace redispp;
using namespace std;
const char* TEST_PORT = "0";
const char* TEST_HOST = "127.0.0.1";
const char* TEST_UNIX_DOMAIN_SOCKET = "/tmp/redis.sock";
int main(int argc, char* argv[]) {
#ifdef _WIN32
WSADATA wsaData;
WORD version;
version = MAKEWORD(2, 0);
WSAStartup(version, &wsaData);
#endif
#ifdef UNIX_DOMAIN_SOCKET
Connection conn(TEST_UNIX_DOMAIN_SOCKET, "");
#else
Connection conn(TEST_HOST, TEST_PORT, "");
#endif
int length = conn.llen("list");
printf("Length: %d\n", length);
if (argc > 1) {
int targetLength = atoi(argv[1]);
const size_t chunkFactor = 256;
IntReply replies[chunkFactor];
string key = "list";
string value = "abcdefghijklmnopqrstuvwxyz";
while (value.length() < 1400) {
value = value + value;
}
for (int i = 0; length < targetLength; ++i, ++length) {
replies[i & (chunkFactor - 1)] = conn.lpush(key, value);
}
length = conn.llen("list");
printf("New Length: %d\n", length);
}
MultiBulkEnumerator result = conn.lrange("list", length - 10000, -1);
string data;
while (result.next(&data)) {
printf("Data: %s\n", data.c_str());
}
return 0;
}