Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/sw/redis++/async_redis.h
Original file line number Diff line number Diff line change
Expand Up @@ -514,13 +514,13 @@ class AsyncRedis {
// LIST commands.

Future<OptionalStringPair> blpop(const StringView &key,
const std::chrono::seconds &timeout = std::chrono::seconds{0}) {
const std::chrono::duration<double> &timeout = std::chrono::seconds{0}) {
return _command<OptionalStringPair>(fmt::blpop, key, timeout);
}

template <typename Callback>
auto blpop(const StringView &key,
const std::chrono::seconds &timeout,
const std::chrono::duration<double> &timeout,
Callback &&cb)
-> typename std::enable_if<IsInvocable<typename std::decay<Callback>::type, Future<OptionalStringPair> &&>::value, void>::type {
_callback_fmt_command<OptionalStringPair>(std::forward<Callback>(cb), fmt::blpop, key, timeout);
Expand All @@ -536,7 +536,7 @@ class AsyncRedis {
template <typename Input>
Future<OptionalStringPair> blpop(Input first,
Input last,
const std::chrono::seconds &timeout = std::chrono::seconds{0}) {
const std::chrono::duration<double> &timeout = std::chrono::seconds{0}) {
range_check("BLPOP", first, last);

return _command<OptionalStringPair>(fmt::blpop_range<Input>, first, last, timeout);
Expand All @@ -545,7 +545,7 @@ class AsyncRedis {
template <typename Input, typename Callback>
auto blpop(Input first,
Input last,
const std::chrono::seconds &timeout,
const std::chrono::duration<double> &timeout,
Callback &&cb)
-> typename std::enable_if<IsInvocable<typename std::decay<Callback>::type, Future<OptionalStringPair> &&>::value, void>::type {
range_check("BLPOP", first, last);
Expand All @@ -563,13 +563,13 @@ class AsyncRedis {

template <typename T>
Future<OptionalStringPair> blpop(std::initializer_list<T> il,
const std::chrono::seconds &timeout = std::chrono::seconds{0}) {
const std::chrono::duration<double> &timeout = std::chrono::seconds{0}) {
return blpop(il.begin(), il.end(), timeout);
}

template <typename T, typename Callback>
auto blpop(std::initializer_list<T> il,
const std::chrono::seconds &timeout,
const std::chrono::duration<double> &timeout,
Callback &&cb)
-> typename std::enable_if<IsInvocable<typename std::decay<Callback>::type, Future<OptionalStringPair> &&>::value, void>::type {
return blpop(il.begin(), il.end(), timeout, std::forward<Callback>(cb));
Expand All @@ -583,13 +583,13 @@ class AsyncRedis {
}

Future<OptionalStringPair> brpop(const StringView &key,
const std::chrono::seconds &timeout = std::chrono::seconds{0}) {
const std::chrono::duration<double> &timeout = std::chrono::seconds{0}) {
return _command<OptionalStringPair>(fmt::brpop, key, timeout);
}

template <typename Callback>
auto brpop(const StringView &key,
const std::chrono::seconds &timeout,
const std::chrono::duration<double> &timeout,
Callback &&cb)
-> typename std::enable_if<IsInvocable<typename std::decay<Callback>::type, Future<OptionalStringPair> &&>::value, void>::type {
_callback_fmt_command<OptionalStringPair>(std::forward<Callback>(cb), fmt::brpop, key, timeout);
Expand All @@ -605,7 +605,7 @@ class AsyncRedis {
template <typename Input>
Future<OptionalStringPair> brpop(Input first,
Input last,
const std::chrono::seconds &timeout = std::chrono::seconds{0}) {
const std::chrono::duration<double> &timeout = std::chrono::seconds{0}) {
range_check("BRPOP", first, last);

return _command<OptionalStringPair>(fmt::brpop_range<Input>, first, last, timeout);
Expand All @@ -614,7 +614,7 @@ class AsyncRedis {
template <typename Input, typename Callback>
auto brpop(Input first,
Input last,
const std::chrono::seconds &timeout,
const std::chrono::duration<double> &timeout,
Callback &&cb)
-> typename std::enable_if<IsInvocable<typename std::decay<Callback>::type, Future<OptionalStringPair> &&>::value, void>::type {
range_check("BRPOP", first, last);
Expand All @@ -632,13 +632,13 @@ class AsyncRedis {

template <typename T>
Future<OptionalStringPair> brpop(std::initializer_list<T> il,
const std::chrono::seconds &timeout = std::chrono::seconds{0}) {
const std::chrono::duration<double> &timeout = std::chrono::seconds{0}) {
return brpop(il.begin(), il.end(), timeout);
}

template <typename T, typename Callback>
auto brpop(std::initializer_list<T> il,
const std::chrono::seconds &timeout,
const std::chrono::duration<double> &timeout,
Callback &&cb)
-> typename std::enable_if<IsInvocable<typename std::decay<Callback>::type, Future<OptionalStringPair> &&>::value, void>::type {
return brpop(il.begin(), il.end(), timeout, std::forward<Callback>(cb));
Expand All @@ -653,14 +653,14 @@ class AsyncRedis {

Future<OptionalString> brpoplpush(const StringView &source,
const StringView &destination,
const std::chrono::seconds &timeout = std::chrono::seconds{0}) {
const std::chrono::duration<double> &timeout = std::chrono::seconds{0}) {
return _command<OptionalString>(fmt::brpoplpush, source, destination, timeout);
}

template <typename Callback>
auto brpoplpush(const StringView &source,
const StringView &destination,
const std::chrono::seconds &timeout,
const std::chrono::duration<double> &timeout,
Callback &&cb)
-> typename std::enable_if<IsInvocable<typename std::decay<Callback>::type, Future<OptionalString> &&>::value, void>::type {
_callback_fmt_command<OptionalString>(std::forward<Callback>(cb), fmt::brpoplpush, source, destination, timeout);
Expand Down Expand Up @@ -846,14 +846,14 @@ class AsyncRedis {

Future<OptionalString> blmove(const StringView &src, const StringView &dest,
ListWhence src_whence, ListWhence dest_whence,
const std::chrono::seconds &timeout = std::chrono::seconds{0}) {
const std::chrono::duration<double> &timeout = std::chrono::seconds{0}) {
return _command<OptionalString>(fmt::blmove, src, dest, src_whence, dest_whence, timeout.count());
}

template <typename Callback>
void blmove(const StringView &src, const StringView &dest,
ListWhence src_whence, ListWhence dest_whence,
const std::chrono::seconds &timeout, Callback &&cb) {
const std::chrono::duration<double> &timeout, Callback &&cb) {
_callback_fmt_command<OptionalString>(std::forward<Callback>(cb), fmt::blmove, src, dest,
src_whence, dest_whence, timeout.count());
}
Expand Down
18 changes: 9 additions & 9 deletions src/sw/redis++/async_redis_cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,48 +387,48 @@ class AsyncRedisCluster {
// LIST commands.

Future<OptionalStringPair> blpop(const StringView &key,
const std::chrono::seconds &timeout = std::chrono::seconds{0}) {
const std::chrono::duration<double> &timeout = std::chrono::seconds{0}) {
return _command<OptionalStringPair>(fmt::blpop, key, timeout);
}

template <typename Input>
Future<OptionalStringPair> blpop(Input first,
Input last,
const std::chrono::seconds &timeout = std::chrono::seconds{0}) {
const std::chrono::duration<double> &timeout = std::chrono::seconds{0}) {
range_check("BLPOP", first, last);

return _command<OptionalStringPair>(fmt::blpop_range<Input>, first, last, timeout);
}

template <typename T>
Future<OptionalStringPair> blpop(std::initializer_list<T> il,
const std::chrono::seconds &timeout = std::chrono::seconds{0}) {
const std::chrono::duration<double> &timeout = std::chrono::seconds{0}) {
return blpop(il.begin(), il.end(), timeout);
}

Future<OptionalStringPair> brpop(const StringView &key,
const std::chrono::seconds &timeout = std::chrono::seconds{0}) {
const std::chrono::duration<double> &timeout = std::chrono::seconds{0}) {
return _command<OptionalStringPair>(fmt::brpop, key, timeout);
}

template <typename Input>
Future<OptionalStringPair> brpop(Input first,
Input last,
const std::chrono::seconds &timeout = std::chrono::seconds{0}) {
const std::chrono::duration<double> &timeout = std::chrono::seconds{0}) {
range_check("BRPOP", first, last);

return _command<OptionalStringPair>(fmt::brpop_range<Input>, first, last, timeout);
}

template <typename T>
Future<OptionalStringPair> brpop(std::initializer_list<T> il,
const std::chrono::seconds &timeout = std::chrono::seconds{0}) {
const std::chrono::duration<double> &timeout = std::chrono::seconds{0}) {
return brpop(il.begin(), il.end(), timeout);
}

Future<OptionalString> brpoplpush(const StringView &source,
const StringView &destination,
const std::chrono::seconds &timeout = std::chrono::seconds{0}) {
const std::chrono::duration<double> &timeout = std::chrono::seconds{0}) {
return _command<OptionalString>(fmt::brpoplpush, source, destination, timeout);
}

Expand Down Expand Up @@ -528,14 +528,14 @@ class AsyncRedisCluster {

Future<OptionalString> blmove(const StringView &src, const StringView &dest,
ListWhence src_whence, ListWhence dest_whence,
const std::chrono::seconds &timeout = std::chrono::seconds{0}) {
const std::chrono::duration<double> &timeout = std::chrono::seconds{0}) {
return _command<OptionalString>(fmt::blmove, src, dest, src_whence, dest_whence, timeout.count());
}

template <typename Callback>
void blmove(const StringView &src, const StringView &dest,
ListWhence src_whence, ListWhence dest_whence,
const std::chrono::seconds &timeout, Callback &&cb) {
const std::chrono::duration<double> &timeout, Callback &&cb) {
_callback_fmt_command<OptionalString>(std::forward<Callback>(cb), fmt::blmove, src, dest,
src_whence, dest_whence, timeout.count());
}
Expand Down
20 changes: 10 additions & 10 deletions src/sw/redis++/cmd_formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,12 @@ inline FormattedCommand strlen(const StringView &key) {
return format_cmd("STRLEN %b", key.data(), key.size());
}

inline FormattedCommand blpop(const StringView &key, const std::chrono::seconds &timeout) {
return format_cmd("BLPOP %b %lld", key.data(), key.size(), timeout.count());
inline FormattedCommand blpop(const StringView &key, const std::chrono::duration<double> &timeout) {
return format_cmd("BLPOP %b %f", key.data(), key.size(), timeout.count());
}

template <typename Input>
FormattedCommand blpop_range(Input first, Input last, const std::chrono::seconds &timeout) {
FormattedCommand blpop_range(Input first, Input last, const std::chrono::duration<double> &timeout) {
assert(first != last);

CmdArgs args;
Expand All @@ -295,13 +295,13 @@ FormattedCommand blpop_range(Input first, Input last, const std::chrono::seconds
return format_cmd(args);
}

inline FormattedCommand brpop(const StringView &key, const std::chrono::seconds &timeout) {
return format_cmd("BRPOP %b %lld", key.data(), key.size(), timeout.count());
inline FormattedCommand brpop(const StringView &key, const std::chrono::duration<double> &timeout) {
return format_cmd("BRPOP %b %f", key.data(), key.size(), timeout.count());
}


template <typename Input>
FormattedCommand brpop_range(Input first, Input last, const std::chrono::seconds &timeout) {
FormattedCommand brpop_range(Input first, Input last, const std::chrono::duration<double> &timeout) {
assert(first != last);

CmdArgs args;
Expand All @@ -312,8 +312,8 @@ FormattedCommand brpop_range(Input first, Input last, const std::chrono::seconds

inline FormattedCommand brpoplpush(const StringView &source,
const StringView &destination,
const std::chrono::seconds &timeout) {
return format_cmd("BRPOPLPUSH %b %b %lld",
const std::chrono::duration<double> &timeout) {
return format_cmd("BRPOPLPUSH %b %b %f",
source.data(), source.size(),
destination.data(), destination.size(),
timeout.count());
Expand Down Expand Up @@ -401,10 +401,10 @@ inline FormattedCommand lmove(const StringView &src, const StringView &dest,
}

inline FormattedCommand blmove(const StringView &src, const StringView &dest,
ListWhence src_whence, ListWhence dest_whence, long long timeout) {
ListWhence src_whence, ListWhence dest_whence, double timeout) {
auto src_whence_str = to_string(src_whence);
auto dest_whence_str = to_string(dest_whence);
return format_cmd("BLMOVE %b %b %s %s %lld",
return format_cmd("BLMOVE %b %b %s %s %f",
src.data(), src.size(),
dest.data(), dest.size(),
src_whence_str.data(), dest_whence_str.data(), timeout);
Expand Down
20 changes: 10 additions & 10 deletions src/sw/redis++/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,8 @@ inline void strlen(Connection &connection, const StringView &key) {

// LIST commands.

inline void blpop(Connection &connection, const StringView &key, long long timeout) {
connection.send("BLPOP %b %lld",
inline void blpop(Connection &connection, const StringView &key, double timeout) {
connection.send("BLPOP %b %f",
key.data(), key.size(),
timeout);
}
Expand All @@ -474,7 +474,7 @@ template <typename Input>
inline void blpop_range(Connection &connection,
Input first,
Input last,
long long timeout) {
double timeout) {
assert(first != last);

CmdArgs args;
Expand All @@ -483,8 +483,8 @@ inline void blpop_range(Connection &connection,
connection.send(args);
}

inline void brpop(Connection &connection, const StringView &key, long long timeout) {
connection.send("BRPOP %b %lld",
inline void brpop(Connection &connection, const StringView &key, double timeout) {
connection.send("BRPOP %b %f",
key.data(), key.size(),
timeout);
}
Expand All @@ -493,7 +493,7 @@ template <typename Input>
inline void brpop_range(Connection &connection,
Input first,
Input last,
long long timeout) {
double timeout) {
assert(first != last);

CmdArgs args;
Expand All @@ -505,8 +505,8 @@ inline void brpop_range(Connection &connection,
inline void brpoplpush(Connection &connection,
const StringView &source,
const StringView &destination,
long long timeout) {
connection.send("BRPOPLPUSH %b %b %lld",
double timeout) {
connection.send("BRPOPLPUSH %b %b %f",
source.data(), source.size(),
destination.data(), destination.size(),
timeout);
Expand Down Expand Up @@ -660,10 +660,10 @@ inline void lmove(Connection &connection, const StringView &src, const StringVie
}

inline void blmove(Connection &connection, const StringView &src, const StringView &dest,
ListWhence src_whence, ListWhence dest_whence, long long timeout) {
ListWhence src_whence, ListWhence dest_whence, double timeout) {
auto src_whence_str = to_string(src_whence);
auto dest_whence_str = to_string(dest_whence);
connection.send("BLMOVE %b %b %s %s %lld",
connection.send("BLMOVE %b %b %s %s %f",
src.data(), src.size(),
dest.data(), dest.size(),
src_whence_str.data(), dest_whence_str.data(), timeout);
Expand Down
Loading