Skip to content

Commit 5b19d4a

Browse files
committed
fix
1 parent f38bc10 commit 5b19d4a

File tree

7 files changed

+50
-54
lines changed

7 files changed

+50
-54
lines changed

include/cppredis/client.hpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ namespace cpp_redis {
627627
}
628628

629629
template<typename T>
630-
RESULTS_TYPE list_range(T&& key, int start, int end)
630+
std::vector <std::string> list_range(T&& key, int start, int end)
631631
{
632632
static_assert(is_list_, "This API Support List Request");
633633

@@ -930,7 +930,7 @@ namespace cpp_redis {
930930

931931
//只是随机,不会发生删除
932932
template<typename T>
933-
RESULTS_TYPE set_rand_elem(T&& key, int count)
933+
std::vector <std::string> set_rand_elem(T&& key, int count)
934934
{
935935
static_assert(is_set_, "This API Support Set Request");
936936
if (client_ == nullptr) {
@@ -982,7 +982,7 @@ namespace cpp_redis {
982982
}
983983

984984
template<typename T>
985-
RESULTS_TYPE set_get_all_member(T&& key)
985+
std::vector <std::string> set_get_all_member(T&& key)
986986
{
987987
static_assert(is_set_, "This API Support Set Request");
988988
if (client_== nullptr) {
@@ -1001,7 +1001,7 @@ namespace cpp_redis {
10011001

10021002
//求集合的交集,如果一个为空,就返回空
10031003
template<typename T,typename...Args>
1004-
RESULTS_TYPE set_sinter(T&&key,Args&&...keys)
1004+
std::vector <std::string> set_sinter(T&&key,Args&&...keys)
10051005
{
10061006
constexpr auto Size = sizeof...(keys)+1;
10071007
static_assert(is_set_, "This API Support Set Request");
@@ -1036,7 +1036,7 @@ namespace cpp_redis {
10361036
//求集合的并集合,不存在key就视为空
10371037
//(返回一个集合的全部成员,该集合是所有给定集合的并集)
10381038
template<typename...Args>
1039-
RESULTS_TYPE set_union(Args&&...key)
1039+
std::vector <std::string> set_union(Args&&...key)
10401040
{
10411041
constexpr auto Size = sizeof...(key);
10421042
static_assert(is_set_, "This API Support Set Request");
@@ -1075,7 +1075,7 @@ namespace cpp_redis {
10751075
//返回一个集合的全部成员,该集合是所有给定集合之间的差集。
10761076
//不存在的 key 被视为空集。
10771077
template<typename...Args>
1078-
RESULTS_TYPE set_diff(Args&&...key)
1078+
std::vector <std::string> set_diff(Args&&...key)
10791079
{
10801080
constexpr auto Size = sizeof...(key);
10811081
static_assert(is_set_, "This API Support Set Request");
@@ -1206,7 +1206,7 @@ namespace cpp_redis {
12061206
//with_scores:false不带score返回
12071207
//递增排序
12081208
template<typename T>
1209-
RESULTS_TYPE zset_range(T&& key, int begin, int end, bool with_scores = true)
1209+
std::vector <std::string> zset_range(T&& key, int begin, int end, bool with_scores = true)
12101210
{
12111211
static_assert(is_zset, "This API Support ZSet Request");
12121212

@@ -1226,7 +1226,7 @@ namespace cpp_redis {
12261226
//递减排序
12271227
//字典序的逆序
12281228
template<typename T>
1229-
RESULTS_TYPE zset_rerange(T&& key, int begin, int end, bool with_scores = true)
1229+
std::vector <std::string> zset_rerange(T&& key, int begin, int end, bool with_scores = true)
12301230
{
12311231
static_assert(is_zset, "This API Support ZSet Request");
12321232
if (client_ == nullptr){
@@ -1243,7 +1243,7 @@ namespace cpp_redis {
12431243

12441244
//求区间内的score排序
12451245
template<typename T>
1246-
RESULTS_TYPE zset_range_score(T&& key, int min, int max,
1246+
std::vector <std::string> zset_range_score(T&& key, int min, int max,
12471247
bool with_scores = true, bool limit = false, int limit_min = 0, int limit_max = 1)
12481248
{
12491249
static_assert(is_zset, "This API Support ZSet Request");
@@ -1264,7 +1264,7 @@ namespace cpp_redis {
12641264

12651265
//求区间内的score从数据库中逆向取值并排序
12661266
template<typename T>
1267-
RESULTS_TYPE zset_revrange_score(T&& key, int max, int min,
1267+
std::vector <std::string> zset_revrange_score(T&& key, int max, int min,
12681268
bool with_scores = true, bool limit = false, int limit_min = 0, int limit_max = 1)
12691269
{
12701270
static_assert(is_zset, "This API Support ZSet Request");
@@ -1388,7 +1388,7 @@ namespace cpp_redis {
13881388
//因此, 向一个所有成员的分值都相同的有序集合发送命令 ZRANGEBYLEX <zset> -+, 命令将返回有序集合中的所有元素。
13891389

13901390
template<typename T>
1391-
RESULTS_TYPE zset_rangebylex(T&& key,std::string&&min,std::string&& max,bool limit=false,int limit_min=0,int limit_max=1)
1391+
std::vector <std::string> zset_rangebylex(T&& key,std::string&&min,std::string&& max,bool limit=false,int limit_min=0,int limit_max=1)
13921392
{
13931393
static_assert(is_zset, "This API Support ZSet Request");
13941394

@@ -1695,7 +1695,7 @@ namespace cpp_redis {
16951695
}
16961696

16971697
template<typename T,typename...Args>
1698-
RESULTS_TYPE hash_mget(T&& key, Args&&...keys)
1698+
std::vector <std::string> hash_mget(T&& key, Args&&...keys)
16991699
{
17001700
const auto Size = sizeof...(keys) + 1;
17011701
static_assert(is_hash, "This API Support hash Request");
@@ -1715,7 +1715,7 @@ namespace cpp_redis {
17151715

17161716
//返回所有的keys
17171717
template<typename T>
1718-
RESULTS_TYPE hash_keys(T&& key)
1718+
std::vector <std::string> hash_keys(T&& key)
17191719
{
17201720
static_assert(is_hash, "This API Support hash Request");
17211721
if (client_ == nullptr) {
@@ -1733,7 +1733,7 @@ namespace cpp_redis {
17331733

17341734
//返回key中的所有值
17351735
template<typename T>
1736-
RESULTS_TYPE hash_vals(T&& key)
1736+
std::vector <std::string> hash_vals(T&& key)
17371737
{
17381738
static_assert(is_hash, "This API Support hash Request");
17391739
if (client_ == nullptr) {
@@ -1751,7 +1751,7 @@ namespace cpp_redis {
17511751

17521752
//返回key中的域和值
17531753
template<typename T>
1754-
RESULTS_TYPE hash_get_all(T&& key)
1754+
std::vector <std::string> hash_get_all(T&& key)
17551755
{
17561756
static_assert(is_hash, "This API Support hash Request");
17571757
if (client_ == nullptr) {

include/cppredis/client_interface.hpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ namespace cpp_redis {
296296
return -1;
297297
}
298298

299-
virtual RESULTS_TYPE list_range(std::string&& key, int start, int end)
299+
virtual std::vector<std::string> list_range(std::string&& key, int start, int end)
300300
{
301301
return {};
302302
}
@@ -380,7 +380,7 @@ namespace cpp_redis {
380380
return "";
381381
}
382382

383-
virtual RESULTS_TYPE set_sinter(std::vector<std::string>&& keys)
383+
virtual std::vector <std::string> set_sinter(std::vector<std::string>&& keys)
384384
{
385385
return {};
386386
}
@@ -390,7 +390,7 @@ namespace cpp_redis {
390390
return 0;
391391
}
392392

393-
virtual RESULTS_TYPE set_union(std::vector<std::string>&& keys)
393+
virtual std::vector <std::string> set_union(std::vector<std::string>&& keys)
394394
{
395395
return {};
396396
}
@@ -400,7 +400,7 @@ namespace cpp_redis {
400400
return 0;
401401
}
402402

403-
virtual RESULTS_TYPE set_rand_elem(std::string&& key, int count)
403+
virtual std::vector <std::string> set_rand_elem(std::string&& key, int count)
404404
{
405405
return {};
406406
}
@@ -410,7 +410,7 @@ namespace cpp_redis {
410410
return false;
411411
}
412412

413-
virtual RESULTS_TYPE set_diff(std::vector<std::string>&& keys)
413+
virtual std::vector <std::string> set_diff(std::vector<std::string>&& keys)
414414
{
415415
return {};
416416
}
@@ -419,7 +419,7 @@ namespace cpp_redis {
419419
{
420420
return 0;
421421
}
422-
virtual RESULTS_TYPE set_get_all_member(std::string&& key)
422+
virtual std::vector <std::string> set_get_all_member(std::string&& key)
423423
{
424424
return {};
425425
}
@@ -452,23 +452,23 @@ namespace cpp_redis {
452452
return 0;
453453
}
454454

455-
virtual RESULTS_TYPE zset_range(std::string&& key, std::string&& begin, std::string&& end,bool with_scores)
455+
virtual std::vector <std::string> zset_range(std::string&& key, std::string&& begin, std::string&& end,bool with_scores)
456456
{
457457
return { {} };
458458
}
459459

460-
virtual RESULTS_TYPE zset_revrange(std::string&& key, std::string&& begin, std::string&& end, bool with_scores)
460+
virtual std::vector <std::string> zset_revrange(std::string&& key, std::string&& begin, std::string&& end, bool with_scores)
461461
{
462462
return { {} };
463463
}
464464

465-
virtual RESULTS_TYPE zset_range_score(std::string&& key, std::string&& min, std::string&& max,
465+
virtual std::vector <std::string> zset_range_score(std::string&& key, std::string&& min, std::string&& max,
466466
bool with_scores, bool limit, std::string&& limit_min, std::string&& limit_max)
467467
{
468468
return { {} };
469469
}
470470

471-
virtual RESULTS_TYPE zset_revrange_score(std::string&& key, std::string&& max, std::string&& min,
471+
virtual std::vector <std::string> zset_revrange_score(std::string&& key, std::string&& max, std::string&& min,
472472
bool with_scores, bool limit, std::string&& limit_min,std::string&&limit_max)
473473
{
474474
return { {} };
@@ -497,7 +497,7 @@ namespace cpp_redis {
497497
{
498498
return -1;
499499
}
500-
virtual RESULTS_TYPE zset_rangebylex(std::string&& key, std::string&& min,
500+
virtual std::vector <std::string> zset_rangebylex(std::string&& key, std::string&& min,
501501
std::string&& max, bool limit, std::string&& limit_min, std::string&& limit_max)
502502
{
503503
return { {} };
@@ -573,22 +573,22 @@ namespace cpp_redis {
573573
return false;
574574
}
575575

576-
virtual RESULTS_TYPE hash_mget(std::vector<std::string>&& keys)
576+
virtual std::vector <std::string> hash_mget(std::vector<std::string>&& keys)
577577
{
578578
return { {} };
579579
}
580580

581-
virtual RESULTS_TYPE hash_keys(std::string&& key)
581+
virtual std::vector <std::string> hash_keys(std::string&& key)
582582
{
583583
return{ {} };
584584
}
585585

586-
virtual RESULTS_TYPE hash_vals(std::string&& key)
586+
virtual std::vector <std::string> hash_vals(std::string&& key)
587587
{
588588
return{ {} };
589589
}
590590

591-
virtual RESULTS_TYPE hash_get_all(std::string&& key)
591+
virtual std::vector <std::string> hash_get_all(std::string&& key)
592592
{
593593
return{ {} };
594594
}

include/cppredis/cpp_hash_client.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ namespace cpp_redis
217217
return true;
218218
}
219219

220-
virtual RESULTS_TYPE hash_mget(std::vector<std::string>&& keys)
220+
virtual std::vector <std::string> hash_mget(std::vector<std::string>&& keys)
221221
{
222222
std::string msg = request_->req_n_keys(request_->get_cmd(redis_cmd::hash_mget), std::forward<std::vector<std::string>>(keys));
223223
socket_->send_msg(std::move(msg));
@@ -232,7 +232,7 @@ namespace cpp_redis
232232
}
233233

234234
//返回所有的keys
235-
virtual RESULTS_TYPE hash_keys(std::string&& key)
235+
virtual std::vector <std::string> hash_keys(std::string&& key)
236236
{
237237
std::string msg = request_->req_n_key(request_->get_cmd(redis_cmd::hash_keys), std::forward<std::string>(key));
238238
socket_->send_msg(std::move(msg));
@@ -248,7 +248,7 @@ namespace cpp_redis
248248

249249

250250
//返回key中的所有值
251-
virtual RESULTS_TYPE hash_vals(std::string&& key)
251+
virtual std::vector <std::string> hash_vals(std::string&& key)
252252
{
253253
std::string msg = request_->req_n_key(request_->get_cmd(redis_cmd::hash_vals),
254254
std::forward<std::string>(key));
@@ -264,7 +264,7 @@ namespace cpp_redis
264264
}
265265

266266
//返回key中的域和值
267-
virtual RESULTS_TYPE hash_get_all(std::string&& key)
267+
virtual std::vector <std::string> hash_get_all(std::string&& key)
268268
{
269269
std::string msg = request_->req_n_key(request_->get_cmd(redis_cmd::hash_get_all),
270270
std::forward<std::string>(key));

include/cppredis/cpp_redis_list.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ namespace cpp_redis {
109109
}
110110

111111
/************和数组一样,下标从零开始**************************************/
112-
virtual RESULTS_TYPE list_range(std::string&& key, int start, int end)
112+
virtual std::vector <std::string> list_range(std::string&& key, int start, int end)
113113
{
114114
check_args();
115115

include/cppredis/cpp_redis_response.hpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
#include "cpp_define.h"
55

66
namespace cpp_redis {
7-
using RESULTS_TYPE = std::vector<std::string>;
8-
9-
using INT_RESULTS_TYPE = std::vector<int>;
10-
117
class cpp_redis_response {
128
public:
139
void reset()
@@ -44,7 +40,7 @@ namespace cpp_redis {
4440
int_results_.emplace_back(value);
4541
}
4642

47-
INT_RESULTS_TYPE get_int_results()
43+
std::vector<int> get_int_results()
4844
{
4945
return std::move(int_results_);
5046
}
@@ -54,7 +50,7 @@ namespace cpp_redis {
5450
results_.emplace_back(value);
5551
}
5652

57-
RESULTS_TYPE get_results()
53+
std::vector<std::string> get_results()
5854
{
5955
return std::move(results_);
6056
}
@@ -72,8 +68,8 @@ namespace cpp_redis {
7268
int result_code_; //-1: unconnected, 0: results_; 2: int ; 4: err_; 8: status_
7369
std::string err_;
7470
std::string status_;
75-
INT_RESULTS_TYPE int_results_;
76-
RESULTS_TYPE results_;
71+
std::vector<int> int_results_;
72+
std::vector<std::string> results_;
7773
};
7874
}
7975
#endif // cpp_redis_response_h__

include/cppredis/cpp_set_client.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ namespace cpp_redis {
9595
}
9696

9797
//count >0表示元素不会重复, <0表示元素会重复
98-
virtual RESULTS_TYPE set_rand_elem(std::string&& key, int count)
98+
virtual std::vector <std::string> set_rand_elem(std::string&& key, int count)
9999
{
100100
check_args();
101101
std::string msg = request_->req_n_key(request_->get_cmd(redis_cmd::srandmember), std::forward<std::string>(key), std::move(unit::int_to_string(count)));
@@ -155,7 +155,7 @@ namespace cpp_redis {
155155
return resulut[0];
156156
}
157157

158-
virtual RESULTS_TYPE set_get_all_member(std::string&& key)
158+
virtual std::vector <std::string> set_get_all_member(std::string&& key)
159159
{
160160
check_args();
161161
std::string msg = request_->req_n_key(request_->get_cmd(redis_cmd::smembers), std::forward<std::string>(key));
@@ -175,7 +175,7 @@ namespace cpp_redis {
175175
}
176176

177177
//求集合的交集,如果一个为空,就返回空
178-
virtual RESULTS_TYPE set_sinter(std::vector<std::string>&& keys)
178+
virtual std::vector <std::string> set_sinter(std::vector<std::string>&& keys)
179179
{
180180
check_args();
181181
std::string msg = request_->req_n_keys(request_->get_cmd(redis_cmd::sinter),std::forward<std::vector<std::string>>(keys));
@@ -211,7 +211,7 @@ namespace cpp_redis {
211211
//(返回一个集合的全部成员,该集合是所有给定集合的并集)
212212
//A{1:1234,2:5678,37895,4:910245} B{1:1234,2:7895,3:78945}
213213
//A U B={1234,5678,7895,10245}
214-
virtual RESULTS_TYPE set_union(std::vector<std::string>&&keys)
214+
virtual std::vector <std::string> set_union(std::vector<std::string>&&keys)
215215
{
216216
check_args();
217217
std::string msg = request_->req_n_keys(request_->get_cmd(redis_cmd::sunion), std::forward<std::vector<std::string>>(keys));
@@ -252,7 +252,7 @@ namespace cpp_redis {
252252
//返回一个集合的全部成员,该集合是所有给定集合之间的差集。
253253
//不存在的 key 被视为空集。
254254

255-
virtual RESULTS_TYPE set_diff(std::vector<std::string>&& keys)
255+
virtual std::vector <std::string> set_diff(std::vector<std::string>&& keys)
256256
{
257257
check_args();
258258
std::string msg = request_->req_n_keys(request_->get_cmd(redis_cmd::sdiff), std::forward<std::vector<std::string>>(keys));
@@ -265,7 +265,7 @@ namespace cpp_redis {
265265

266266
auto results = res->get_results();
267267

268-
return ((!results.empty()) ? std::move(results) : std::move(RESULTS_TYPE()));
268+
return ((!results.empty()) ? std::move(results) : std::move(std::vector <std::string>()));
269269
}
270270

271271
//返回一个集合的全部成员,该集合是所有给定集合之间的差集。

0 commit comments

Comments
 (0)