2
0
mirror of https://github.com/boostorg/redis.git synced 2026-01-19 04:42:09 +00:00

Adds new redis hash commands.

This commit is contained in:
Marcelo Zimbres
2020-09-19 10:55:46 +02:00
parent cba190c7bd
commit b931cbff57
6 changed files with 43 additions and 9 deletions

View File

@@ -14,7 +14,7 @@ if(AEDIS_USE_CONAN)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/find_conan_packages")
endif()
find_package(Boost 1.71 REQUIRED COMPONENTS system)
find_package(Boost 1.74 REQUIRED COMPONENTS system)
find_package(fmt 7.0 REQUIRED)
add_library(aedis INTERFACE)
@@ -53,4 +53,4 @@ export(
EXPORT aedis-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/aedis-targets.cmake"
NAMESPACE aedis::
)
)

View File

@@ -5,8 +5,10 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
CPPFLAGS += -std=c++17 -g
CPPFLAGS += -I/opt/boost_1_71_0/include
CPPFLAGS += -DBOOST_ASIO_CONCURRENCY_HINT_1=BOOST_ASIO_CONCURRENCY_HINT_UNSAFE
CPPFLAGS += -I/opt/boost_1_74_0/include
CPPFLAGS += -D BOOST_ASIO_CONCURRENCY_HINT_1=BOOST_ASIO_CONCURRENCY_HINT_UNSAFE
CPPFLAGS += -D BOOST_ASIO_NO_DEPRECATED
CPPFLAGS += -D BOOST_ASIO_NO_TS_EXECUTORS
all: examples tests

View File

@@ -470,6 +470,34 @@ auto hset( std::string const& key
return resp::assemble("HSET", {key}, std::cbegin(m), std::cend(m), 2);
}
inline
auto hincrby(std::string const& key, std::string const& field, int by)
{
auto par = {field, std::to_string(by)};
return resp::assemble("HINCRBY", {key}, std::cbegin(par), std::cend(par));
}
inline
auto hkeys(std::string const& key)
{
std::initializer_list<std::string> par;
return resp::assemble("HKEYS", {key}, std::cbegin(par), std::cend(par));
}
inline
auto hlen(std::string const& key)
{
std::initializer_list<std::string> par;
return resp::assemble("HLEN", {key});
}
inline
auto hgetall(std::string const& key)
{
std::initializer_list<std::string> par;
return resp::assemble("HGETALL", {key});
}
inline
auto hvals(std::string const& key)
{

View File

@@ -1,6 +1,6 @@
include(CMakeFindDependencyMacro)
find_dependency(Boost 1.71 COMPONENTS system REQUIRED)
find_dependency(Boost 1.74 COMPONENTS system REQUIRED)
find_dependency(fmt 7.0 REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/aedis-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/aedis-targets.cmake")

View File

@@ -1,6 +1,6 @@
[requires]
boost/1.71.0
boost/1.74.0
fmt/7.0.2
[generators]
cmake
cmake

View File

@@ -101,7 +101,8 @@ void example1()
std::map<std::string, std::string> c
{ {{"Name"}, {"Marcelo"}}
, {{"Education"}, {"Physics"}}
, {{"Job"}, {"Programmer"}}};
, {{"Job"}, {"Programmer"}}
};
std::map<int, std::string> d
{ {1, {"foo"}}
@@ -120,8 +121,11 @@ void example1()
+ lrange("b")
+ del("b")
+ hset("c", c)
+ hincrby("c", "Age", 40)
+ hmget("c", {"Name", "Education", "Job"})
+ hvals("c")
+ hlen("c")
+ hgetall("c")
+ zadd({"d"}, d)
+ zrange("d")
+ zrangebyscore("foo", 2, -1)