Permalink
Browse files

redis, bugfix: fix implement of `RedisSortedSet::add(OptArgs sms, int…

…32_t& retVal)`. (#410)
  • Loading branch information...
richardo2016 authored and xicilion committed Apr 21, 2018
1 parent fd8e4b7 commit c33150e866958ea6dc71b8526192128cb5d5dce4
Showing with 23 additions and 5 deletions.
  1. +15 −0 fibjs/include/Redis.h
  2. +8 −5 fibjs/src/db/redis/RedisSortedSet.cpp
View
@@ -181,6 +181,21 @@ class Redis : public Redis_base {
return 0;
}
template <typename T>
result_t add(std::vector<T>& args)
{
result_t hr;
int32_t i;
for (i = 0; i < args.size(); i++) {
hr = add(args[i]);
if (hr < 0)
return hr;
}
return 0;
}
result_t add(v8::Local<v8::Value> v)
{
result_t hr;
@@ -35,14 +35,17 @@ result_t RedisSortedSet::add(OptArgs sms, int32_t& retVal)
if (sms.Length() & 1)
return CHECK_ERROR(CALL_E_INVALIDARG);
std::vector<v8::Local<v8::Value>> mss;
sms.GetData(mss);
int32_t i;
for (i = 0; i < sms.Length(); i += 2) {
v8::Local<v8::Value> v = sms[i];
sms[i] = sms[i + 1];
sms[i + 1] = v;
for (i = 0; i < mss.size(); i += 2) {
v8::Local<v8::Value> v = mss[i];
mss[i] = mss[i + 1];
mss[i + 1] = v;
}
return m_rdb->doCommand("ZADD", m_key, sms, retVal);
return m_rdb->doCommand("ZADD", m_key, mss, retVal);
}
result_t RedisSortedSet::score(Buffer_base* member, obj_ptr<Buffer_base>& retVal)

0 comments on commit c33150e

Please sign in to comment.