forked from OpenAtomFoundation/pika
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpika_kv.h
305 lines (274 loc) · 6.46 KB
/
pika_kv.h
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
// Copyright (c) 2015-present, Qihoo, Inc. All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
#ifndef PIKA_KV_H_
#define PIKA_KV_H_
#include "pika_command.h"
#include "nemo.h"
/*
* kv
*/
class SetCmd : public Cmd {
public:
enum SetCondition{kANY, kNX, kXX};
SetCmd() : sec_(0), condition_(kANY) {};
virtual void Do();
private:
std::string key_;
std::string value_;
int64_t sec_;
SetCmd::SetCondition condition_;
virtual void DoInitial(PikaCmdArgsType &argvs, const CmdInfo* const ptr_info);
virtual void Clear() {
sec_ = 0;
condition_ = kANY;
}
};
class GetCmd : public Cmd {
public:
GetCmd() {};
virtual void Do();
private:
std::string key_;
virtual void DoInitial(PikaCmdArgsType &argvs, const CmdInfo* const ptr_info);
};
class DelCmd : public Cmd {
public:
DelCmd() {}
virtual void Do();
private:
std::vector<std::string> keys_;
virtual void DoInitial(PikaCmdArgsType &argvs, const CmdInfo* const ptr_info);
};
class IncrCmd : public Cmd {
public:
IncrCmd() {}
virtual void Do();
private:
std::string key_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class IncrbyCmd : public Cmd {
public:
IncrbyCmd() {}
virtual void Do();
private:
std::string key_;
int64_t by_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class IncrbyfloatCmd : public Cmd {
public:
IncrbyfloatCmd() {}
virtual void Do();
private:
std::string key_;
double by_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class DecrCmd : public Cmd {
public:
DecrCmd() {}
virtual void Do();
private:
std::string key_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class DecrbyCmd : public Cmd {
public:
DecrbyCmd() {}
virtual void Do();
private:
std::string key_;
int64_t by_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class GetsetCmd : public Cmd {
public:
GetsetCmd() {}
virtual void Do();
private:
std::string key_;
std::string new_value_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class AppendCmd : public Cmd {
public:
AppendCmd() {}
virtual void Do();
private:
std::string key_;
std::string value_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class MgetCmd : public Cmd {
public:
MgetCmd() {}
virtual void Do();
private:
std::vector<std::string> keys_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class KeysCmd : public Cmd {
public:
KeysCmd() {}
virtual void Do();
private:
std::string pattern_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class SetnxCmd : public Cmd {
public:
SetnxCmd() {}
virtual void Do();
private:
std::string key_;
std::string value_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class SetexCmd : public Cmd {
public:
SetexCmd() {}
virtual void Do();
private:
std::string key_;
int64_t sec_;
std::string value_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class MsetCmd : public Cmd {
public:
MsetCmd() {}
virtual void Do();
private:
std::vector<nemo::KV> kvs_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class MsetnxCmd : public Cmd {
public:
MsetnxCmd() {}
virtual void Do();
private:
std::vector<nemo::KV> kvs_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class GetrangeCmd : public Cmd {
public:
GetrangeCmd() {}
virtual void Do();
private:
std::string key_;
int64_t start_;
int64_t end_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class SetrangeCmd : public Cmd {
public:
SetrangeCmd() {}
virtual void Do();
private:
std::string key_;
int64_t offset_;
std::string value_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class StrlenCmd : public Cmd {
public:
StrlenCmd() {}
virtual void Do();
private:
std::string key_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class ExistsCmd : public Cmd {
public:
ExistsCmd() {}
virtual void Do();
private:
std::vector<std::string> keys_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class ExpireCmd : public Cmd {
public:
ExpireCmd() {}
virtual void Do();
private:
std::string key_;
int64_t sec_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class PexpireCmd : public Cmd {
public:
PexpireCmd() {}
virtual void Do();
private:
std::string key_;
int64_t msec_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class ExpireatCmd : public Cmd {
public:
ExpireatCmd() {}
virtual void Do();
private:
std::string key_;
int64_t time_stamp_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class PexpireatCmd : public Cmd {
public:
PexpireatCmd() {}
virtual void Do();
private:
std::string key_;
int64_t time_stamp_ms_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class TtlCmd : public Cmd {
public:
TtlCmd() {}
virtual void Do();
private:
std::string key_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class PttlCmd : public Cmd {
public:
PttlCmd() {}
virtual void Do();
private:
std::string key_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class PersistCmd : public Cmd {
public:
PersistCmd() {}
virtual void Do();
private:
std::string key_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class TypeCmd : public Cmd {
public:
TypeCmd() {}
virtual void Do();
private:
std::string key_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
};
class ScanCmd : public Cmd {
public:
ScanCmd() : pattern_("*"), count_(10) {}
virtual void Do();
private:
int64_t cursor_;
std::string pattern_;
int64_t count_;
virtual void DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info);
virtual void Clear() {
pattern_ = "*";
count_ = 10;
}
};
#endif