Code Monkey home page Code Monkey logo

redis3m's Introduction

redis3m

Build Status Gitter

A C++ Redis client, born to bring my experience using Redis and C++ on a opensource library.

Main goals

  1. Provide a simple and efficient wrapper of hiredis, with C++ facilities like memory management
  2. A connection pooling system, with support for high availability using sentinel
  3. A set of useful patterns ready to use and composable with other code. For example scheduler, orm, counters or message queueing

Dependencies

redis3m requires hiredis and boost libraries.

Install

First step install all required dependencies, on a Debian system you can use:

sudo apt-get install libmsgpack-dev libboost-thread-dev libboost-date-time-dev libboost-test-dev libboost-filesystem-dev libboost-system-dev libhiredis-dev cmake build-essential libboost-regex-dev

Then checkout the code and compile it

git clone https://github.com/luca3m/redis3m
cd redis3m
cmake
make
sudo make install

Documentation

See examples directory for some examples, you can compile them with:

g++ <example.cpp> $(pkg-config --cflags --libs redis3m) -o <example.bin>

You can find all classes reference here

Versioning

This project uses semantic versioning. In short words versions are named X.Y[.Z]. Changing X means break API changes, Y means new features without breaking old code, Z means bug fixing.

redis3m's People

Contributors

abedra avatar crohn avatar jamesmarlowe avatar karmdanzig avatar luca3m avatar pkyoyetera avatar thousandryans avatar vinnyspb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redis3m's Issues

Able to see the results of the given examples when I compile them on terminal but whenever I compile them on Codeblocks, a compiler I am getting error messages similar to the ones attached.

/home/mukul/redis3m/include/redis3m/test.o||In function main':| test.cpp|| undefined reference toredis3m::patterns::script_exec::script_exec(std::string const&, bool)'|
test.cpp|| undefined reference to redis3m::patterns::script_exec::exec(boost::shared_ptr<redis3m::connection>, std::vector<std::string, std::allocator<std::string> > const&, std::vector<std::string, std::allocator<std::string> > const&)'| /home/mukul/redis3m/include/redis3m/test.o||In functionredis3m::connection::create(std::string const&, unsigned int)':|
test.cpp:(.text._ZN7redis3m10connection6createERKSsj[_ZN7redis3m10connection6createERKSsj]+0x31)||undefined reference to redis3m::connection::connection(std::string const&, unsigned int)'| /home/mukul/redis3m/include/redis3m/test.o||In functionvoid boost::checked_deleteredis3m::connection(redis3m::connection*)':|
test.cpp:(.text.ZN5boost14checked_deleteIN7redis3m10connectionEEEvPT[ZN5boost14checked_deleteIN7redis3m10connectionEEEvPT]+0x1a)||undefined reference to `redis3m::connection::~connection()'|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

Can reply object be resused ?

I am running multiple commands and reusing reply object sometimes i find abnormal behavior e.g.

command t = command("SET") << "foor" << "bar" ;
reply myreply = conn->run(t);

t = command("GET") << "foor";
myreply = conn->run(t);

exception safe locks/unlocks

I just wonder, why sometimes is explicit locking on a mutex object is used instead of a unique_lock with explicit unlock call.

In the file: redis3m/src/connection_pool.cpp or redis3m/src/simple_pool.cpp I code like that:

connection::ptr_t simple_pool::get()
{
    connection::ptr_t ret;

    access_mutex.lock();
    std::set<connection::ptr_t>::iterator it = connections.begin();
    if (it != connections.end())
    {
        ret = *it;
        connections.erase(it);
    }

    access_mutex.unlock();

    if (!ret)
    {
        ret = connection::create(_host, _port);
        // Setup connections selecting db
        if (_database != 0)
        {
            ret->run(command("SELECT") << _database);
        }
    }
    return ret;
}

Why not writing it like:

connection::ptr_t simple_pool::get()
{
    connection::ptr_t ret;

    std::unique_lock<std::mutex> lock(access_mutex);
    std::set<connection::ptr_t>::iterator it = connections.begin();
    if (it != connections.end())
    {
        ret = *it;
        connections.erase(it);
    }

    lock.unlock();

    if (!ret)
    {
        ret = connection::create(_host, _port);
        // Setup connections selecting db
        if (_database != 0)
        {
            ret->run(command("SELECT") << _database);
        }
    }
    return ret;
}

In fact unique_lock is used 30 lines below...

I understand that set::erase(iterator) version has the nothrow guarantee, but still I think consistency would be better. And there is no performance drawback in that case.

Binary Strings (having a \0) not propery retrieved

Hi,

When I store a binary string (in redis-cli this looks like "\r\x04\x00\x04\x05")
it will not be properly retrieved.
The reply will be cut off and look like this.
{_type=STRING (1) _str="\r\x4" _integer=0 ...}

Is there any workaround or pending fix? Otherwise I have to use another library :(

Regards

Build Issue: pthread

Hello. For installing redis3m, I followed the following step:

  1. cmake CMakeList.txt
dkkim930122@dkkim930122:~/redis3m-master$ cmake CMakeLists.txt
-- Boost version: 1.54.0
-- Found the following Boost libraries:
--   system
--   filesystem
--   unit_test_framework
--   date_time
--   regex
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dkkim930122/redis3m-master
  1. make
    As I did make, I got the following error:
[  5%] Built target apidoc
Scanning dependencies of target redis3m
[ 10%] Building CXX object CMakeFiles/redis3m.dir/src/cluster_pool.cpp.o
[ 15%] Building CXX object CMakeFiles/redis3m.dir/src/simple_pool.cpp.o
[ 20%] Building CXX object CMakeFiles/redis3m.dir/src/connection.cpp.o
[ 25%] Building CXX object CMakeFiles/redis3m.dir/src/connection_pool.cpp.o
[ 30%] Building CXX object CMakeFiles/redis3m.dir/src/reply.cpp.o
[ 35%] Building CXX object CMakeFiles/redis3m.dir/src/utils/file.cpp.o
[ 40%] Building CXX object CMakeFiles/redis3m.dir/src/utils/logging.cpp.o
[ 45%] Building CXX object CMakeFiles/redis3m.dir/src/utils/resolv.cpp.o
[ 50%] Building CXX object CMakeFiles/redis3m.dir/src/utils/datetime.cpp.o
[ 55%] Building CXX object CMakeFiles/redis3m.dir/src/utils/crc16.cpp.o
[ 60%] Building CXX object CMakeFiles/redis3m.dir/src/utils/sha1.cpp.o
[ 65%] Building CXX object CMakeFiles/redis3m.dir/src/patterns/median_filter.cpp.o
[ 70%] Building CXX object CMakeFiles/redis3m.dir/src/patterns/script_exec.cpp.o
[ 75%] Building CXX object CMakeFiles/redis3m.dir/src/patterns/scheduler.cpp.o
[ 80%] Building CXX object CMakeFiles/redis3m.dir/datadir.cpp.o
Linking CXX shared library libredis3m.so
[ 80%] Built target redis3m
Scanning dependencies of target cluster_pool_test
[ 85%] Building CXX object CMakeFiles/cluster_pool_test.dir/tests/cluster_pool.cpp.o
Linking CXX executable cluster_pool_test
[ 85%] Built target cluster_pool_test
Scanning dependencies of target connection_pool_test
[ 90%] Building CXX object CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o
Linking CXX executable connection_pool_test
/usr/bin/ld: CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [connection_pool_test] Error 1
make[1]: *** [CMakeFiles/connection_pool_test.dir/all] Error 2
make: *** [all] Error 2

Could you help me to solve the error?
I appreciate your time and help!

static library not being installed

I am not familiar with cmake, but when doing 'make install' it only 'installs' shared libs. It would be nice to also install static redis3m.a

Pattern test

Hi,
Just to say that the Pattern test is not passing on my machine.
here is the output:

2/2 Testing: patterns
2/2 Test: patterns
Command: "/home/thomas/redis3m/build/patterns_test"
Directory: /home/thomas/redis3m/build
"patterns" start time: Aug 15 11:33 CEST
Output:
----------------------------------------------------------
Running 6 test cases...
/home/thomas/redis3m/tests/patterns.cpp(82): error in "scheduler_test": check found_id == "testid" failed [ != testid]
/home/thomas/redis3m/tests/patterns.cpp(87): error in "scheduler_test": check found_id == "testid" failed [ != testid]
/home/thomas/redis3m/tests/patterns.cpp(93): error in "scheduler_test": check r.integer() == 0 failed [1 != 0]
/home/thomas/redis3m/tests/patterns.cpp(130): error in "orm_save_test": check restored.loaded() == true failed [false != true]
unknown location(0): fatal error in "orm_save_test": std::exception: std::exception
/home/thomas/redis3m/tests/patterns.cpp(131): last checkpoint
/home/thomas/redis3m/tests/patterns.cpp(150): error in "orm_tracked_key": check id != "" failed [ == ]
unknown location(0): fatal error in "orm_tracked_key": std::exception: std::exception
/home/thomas/redis3m/tests/patterns.cpp(150): last checkpoint

*** 7 failures detected in test suite "redis3m"
<end of output>
Test time =   4.01 sec
----------------------------------------------------------
Test Failed.
"patterns" end time: Aug 15 11:33 CEST
"patterns" time elapsed: 00:00:04
----------------------------------------------------------

Version of software installed:

$> dpkg -l  redis-server libhiredis-dev libboost-dev                
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                                           Version                              Architecture                         Description
+++-==============================================================-====================================-====================================-=================================================================================================================================
ii  libboost-dev                                                   1.54.0.1ubuntu1                      amd64                                Boost C++ Libraries development files (default version)
ii  libhiredis-dev:amd64                                           0.11.0-3                             amd64                                minimalistic C client library for Redis (development files)
ii  redis-server                                                   2:2.8.4-2                            amd64                                Persistent key-value database with network interface

Wouldn't worth it to have the CI running the tests ?

Thanks

Issue: multiple threads can't put the connection back to the pool

I looked at the simple_pool example and the following is my code. Basically what I am trying to do is to create two threads and each of them pushes 500 messages to the server.

void produce(simple_pool::ptr_t pool, int requestPerThread, std::string& nv, int idx)
{
    try
    {
        connection::ptr_t conn = pool->get();

        std::string queue = "queue1";

        if (idx % 2 == 0)
        {
            queue = "queue2";
        }
        for (int i = 0; i < requestPerThread; i++)
        {
            reply r = conn->run(command("RPUSH") << queue << nv);
        }
        std::cout << "thread " << idx << " finished" << std::endl;
        pool->put(conn);
    }
    catch(const transport_failure& ex)
    {
        std::cout << "having transport failure" << std::endl;
    }
}


int main(int argc, char **argv)
{

    int threadCount = 2;
    int requestCount = 1000;
    int requestPerThread = requestCount / threadCount;

    std::string nv = "some long string"

    simple_pool::ptr_t pool = simple_pool::create("10.2.21.28");

    std::vector<Concurrent::JoiningThread> threads;
    threads.reserve(threadCount);

    for (auto idx = 0; idx < threadCount; ++idx)
    {
        threads.emplace_back("name", [&, idx](){produce(pool,requestPerThread, nv, idx);  });
    }

    for (auto & thread : threads)
    {
        thread.join();
    }  
    return 0;
}

When I run the above code, about 30% to 40% of the time, both threads can finish pushing 500 messages to the server and put the connection back to the pool and return successfully. However, the majority of the time, there is one thread that can't finish and never put the connection back to the pool. It gets stuck after the thread sent around 495 messages. The program doesn't terminate but it also doesn't do anything after that.

If I change the threadCount to 1, it succeeds every time and put the connection back to the pool.

Could you please take a look and help me understand what is going on here? Thank you.

connection pool can not recycle

I am using redis3m in productive enviroment. when system is busy and concurrent is high,the simple_pool will establish new connection with redis server.But when system is idle,say midnight,simple_pool can not recycle connection.

127.0.0.1:6379> info clients

Clients

connected_clients:14047
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:1431

build issue

libredis3m.so: undefined reference to `boost::this_thread::hiden::sleep_for(timespec const&)'

version:2.0 / master
env:boost 1.5.6 Ubuntu 12.0.4

How to unsubscribe?

Hi,

The subscriber.cpp example shows how to make an infinite loop that receives messages, but how do I break out of that loop?

I'm running the subcriber in a separate thread, with a connection that is not being used for anything else.
Whenever the get_reply() function returns, it always returns 3 elements: {"message", channelname, content }. But how do I make it stop?

I tried the following in the main thread:
conn->run(command("UNSUBSCRIBE") << channelname);

That is, using the same connection that is being used by the subscriber thread. After this line of code is executed, the get_reply() function in the subscriber thread returns this: { "unsubscribe", channelname, "" }.

So, I found a way for the subcriber thread to unblock and know when to break out of the loop and return: it just needs to check if the first element of the reply is "message" or "unsubscribe".

However, now the call to the unsubscribe command in the main thread blocks forever! How am I supposed to do this then?

Thank you very much!

Redis cluster Pool is not work correctly

Hi Mr,
After compiled the tests/cluster_pool.cpp, It can not run successfully.

There is an error as this output :

Running 2 test cases...
unknown location(0): fatal error in "set_key": std::runtime_error: regex_error
/data/svn/sources/redis3m/tests/cluster_pool.cpp(26): last checkpoint

*** 1 failure detected in test suite "redis3m"

Redis cluster :
Starting 30001 - localhost - master
Starting 30002 - localhost - master
Starting 30003 - localhost - master
Starting 30004 - localhost - slave
Starting 30005 - localhost - slave
Starting 30006 - localhost - slave

Modified code tests/cluster_pool.cpp:

include "common.h"

include <boost/assign/list_of.hpp>

using namespace redis3m;

cluster_pool::ptr_t get_pool()
{
std::vector<std::pair<std::string, unsigned int>> arrPairCluster;
arrPairCluster.push_back(std::pair<std::string, unsigned int>("localhost", 30001));
arrPairCluster.push_back(std::pair<std::string, unsigned int>("localhost", 30002));
arrPairCluster.push_back(std::pair<std::string, unsigned int>("localhost", 30003));
arrPairCluster.push_back(std::pair<std::string, unsigned int>("localhost", 30004));
arrPairCluster.push_back(std::pair<std::string, unsigned int>("localhost", 30005));
arrPairCluster.push_back(std::pair<std::string, unsigned int>("localhost", 30006));
return redis3m::cluster_pool::create(arrPairCluster);
}

BOOST_AUTO_TEST_CASE( create)
{
BOOST_CHECK_NO_THROW(get_pool());
}

BOOST_AUTO_TEST_CASE( set_key)
{
redis3m::cluster_pool::ptr_t pool = get_pool();
BOOST_CHECK_EQUAL("OK", pool->run(command("SET")("foo")("bar")));
BOOST_CHECK_EQUAL("bar", pool->run(command("GET")("foo")));
//BOOST_CHECK_EQUAL(reply::type_t::NIL, pool->run(command("GET")("test")).type());

}

What is wrong in this case ?

Thanks

Leaking memory in constructor

Destructor is not invoked when an exception is thrown in the constructor. Due to this redisContext will not be freed if connection was not established.

redis with haproxy

I'm using redis using haproxy and not managing connections with sentinels. Sentinels is being used for automatic fail-over, when fail-over happens redis3m returns transport_failur which I have put in try catch and haved continued once the exception is caught. But my connection object gets invalid and no other command is running on that object whereas connection with haproxy remains intact. What i want is to refresh redisContext of my connection such that my connection with haproxy does not break and redisContext gets refreshed. I have used redisFreeKeepFd and redisConnectFd but I'm unable to set new context to current connection object.

Get rid of boost

Right now there is a flag NO_BOOST to avoid boost libraries. Get rid of them making it as default.

The only boost library remaining will be boost-unittest.

Comparison function is error for struct host_t

Below code in cluster_pool.h is to define less operator for host_t. The class host_t is used as key in a map.
I think the implemetion has a error.
Below two redis host are different address, they should be as different values and can be inserted into a map. But the current implemention will treat them as the same value ,since the port are the same, the less function will return false.
Please have a look at it.
redis1 : address: 192.168.10.10, port: 6379
redis2 : address: 192.168.10.11, prot: 6379

inline bool operator < (const host_t& rvalue) const
{
      return (address <= rvalue.address) && ( port < rvalue.port);
}

Can sentinels have different ports?

I'm looking at the connection_pool::create() function that receives a list of sentinel hostnames separated by commas. But then it seems that the port number has to be the same for all sentinels. Is there a way to specify different port numbers for each sentinel?

Thank you!

something about simple_pool

hi, recently i use redis3m in my project, i have some questions

  1. how to use simple_pool? there is no example
    simple_pool is an uncopyable class, and do not have a static function, i don't know how to use it?
  2. when i use connection in multi thread, when thread size is 1500 or larger, the iterface run stucks, that is weird

CMake cannot find the Boost libraries on Windows

Gives me this error at the configure stage, even though I manually set the BOOST_ROOT:

Could not find the following Boost libraries:
boost_thread
boost_system
boost_filesystem
boost_unit_test_framework
boost_date_time

Boost 1.56, mingw64 with GCC 4.9.1 and CMake 2.8.12 + 3.0.1

Cannot install dependencies on Centos

sudo apt-get install libmsgpack-dev libboost-thread-dev libboost-date-time-dev libboost-test-dev libboost-filesystem-dev libboost-system-dev libhiredis-dev cmake build-essential

Unable to install these dependencies on redis3m on Centos 7. Is there a way to get around with this?

C++11 support

Hello

I see the code contains a lot of boost code that could easily be replaced by the standard C++11 version. Since redis3m is quite new, why not fully use C++11 ?

Why not establish multiple connections with Master/Slave?

In APIs create_slave_connection() and create_master_connection(), they will return directly after establishing only one connection, so we have at most 2 connections available any time.

Why not make the connection to all Masters & Slaves, then redis3m users have more connections available, which might be better for load sharing.

How to implement lock using redis3m.

Lets say my use case is, There are 2 processes trying to acquire lock on some key. One of them succeed, while other will just wait. Once first one is done updating the value it should release lock and then 2nd process can acquire lock if want or use the value updated by 1st one. I am talking about similar methods from StackExchange.Redis for c#

  1. LockTake
  2. LockRelease
  3. LockExtend
  4. LockQuery

CMake - Boost flag

This is a great project and very solid. Thank you. Also, I have a query...

I build the VS solution and have a problem with the makefile examples project. The lib builds fine.

Also when I try and build with CMAKE I am struggling to disable BOOST using a flag. Seems strange.

Best wishes

binary safe string in redis3m

Hi,
thanks for your contribution first! It is really an awesome and straight forward wrapper.
I did not find the way to send binary safe string in your code, is this not implemented yet or I just missing something?

Thanks for your help!

linking issues with boost causing undefined symbol errors on linux (RHEL 6.5)

Seeing many issues during linking, while building the Redis3m package. I have verified the boost include and lib path and have recent boost release installed (1.54). cut-paste few errors I am seeing below.

Linking CXX executable connection_pool_test
CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In function init_unit_test()': connection_pool.cpp:(.text+0x93): undefined reference toboost::unit_test::framework::master_test_suite()'
CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In function consumer_f(boost::shared_ptr<redis3m::connection_pool>, std::string const&)': connection_pool.cpp:(.text+0x297): undefined reference toboost::this_thread::yield()'
connection_pool.cpp:(.text+0x2a6): undefined reference to boost::this_thread::interruption_requested()' CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In functionproducer_f(boost::shared_ptrredis3m::connection_pool, std::string const&)':
connection_pool.cpp:(.text+0x83c): undefined reference to boost::this_thread::yield()' connection_pool.cpp:(.text+0x84b): undefined reference toboost::this_thread::interruption_requested()'
CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In function test_pool::test_method()': connection_pool.cpp:(.text+0xea0): undefined reference toboost::unit_test::unit_test_log_t::set_checkpoint(boost::unit_test::basic_cstring, unsigned long, boost::unit_test::basic_cstring)'
connection_pool.cpp:(.text+0x10d9): undefined reference to boost::test_tools::tt_detail::check_impl(boost::test_tools::predicate_result const&, boost::unit_test::lazy_ostream const&, boost::unit_test::basic_cstring<char const>, unsigned long, boost::test_tools::tt_detail::tool_level, boost::test_tools::tt_detail::check_type, unsigned long, ...)' CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In functioncrash_test::test_method()':
connection_pool.cpp:(.text+0x16f9): undefined reference to boost::this_thread::disable_interruption::disable_interruption()' connection_pool.cpp:(.text+0x176b): undefined reference toboost::this_thread::disable_interruption::~disable_interruption()'
connection_pool.cpp:(.text+0x194d): undefined reference to boost::this_thread::disable_interruption::~disable_interruption()' CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In functionboost::detail::thread_data<boost::_bi::bind_t<void, void ()(boost::shared_ptrredis3m::connection_pool, std::string const&), boost::_bi::list2boost::_bi::value<boost::shared_ptr<redis3m::connection_pool >, boost::_bi::value<char const> > > >::~thread_data()':
connection_pool.cpp:(.text._ZN5boost6detail11thread_dataINS_3_bi6bind_tIvPFvNS_10shared_ptrIN7redis3m15connection_poolEEERKSsENS2_5list2INS2_5valueIS7_EENSD_IPKcEEEEEEED2Ev[_ZN5boost6detail11thread_dataINS_3_bi6bind_tIvPFvNS_10shared_ptrIN7redis3m15connection_poolEEERKSsENS2_5list2INS2_5valueIS7_EENSD_IPKcEEEEEEED5Ev]+0x36): undefined reference to boost::detail::thread_data_base::~thread_data_base()' connection_pool.cpp:(.text._ZN5boost6detail11thread_dataINS_3_bi6bind_tIvPFvNS_10shared_ptrIN7redis3m15connection_poolEEERKSsENS2_5list2INS2_5valueIS7_EENSD_IPKcEEEEEEED2Ev[_ZN5boost6detail11thread_dataINS_3_bi6bind_tIvPFvNS_10shared_ptrIN7redis3m15connection_poolEEERKSsENS2_5list2INS2_5valueIS7_EENSD_IPKcEEEEEEED5Ev]+0x2b): undefined reference toboost::detail::thread_data_base::~thread_data_base()'
CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In function boost::detail::thread_data<boost::_bi::bind_t<void, void (*)(boost::shared_ptr<redis3m::connection_pool>, std::string const&), boost::_bi::list2<boost::_bi::value<boost::shared_ptr<redis3m::connection_pool> >, boost::_bi::value<char const*> > > >::~thread_data()': connection_pool.cpp:(.text._ZN5boost6detail11thread_dataINS_3_bi6bind_tIvPFvNS_10shared_ptrIN7redis3m15connection_poolEEERKSsENS2_5list2INS2_5valueIS7_EENSD_IPKcEEEEEEED0Ev[_ZN5boost6detail11thread_dataINS_3_bi6bind_tIvPFvNS_10shared_ptrIN7redis3m15connection_poolEEERKSsENS2_5list2INS2_5valueIS7_EENSD_IPKcEEEEEEED0Ev]+0x25): undefined reference toboost::detail::thread_data_base::~thread_data_base()'
connection_pool.cpp:(.text._ZN5boost6detail11thread_dataINS_3_bi6bind_tIvPFvNS_10shared_ptrIN7redis3m15connection_poolEEERKSsENS2_5list2INS2_5valueIS7_EENSD_IPKcEEEEEEED0Ev[_ZN5boost6detail11thread_dataINS_3_bi6bind_tIvPFvNS_10shared_ptrIN7redis3m15connection_poolEEERKSsENS2_5list2INS2_5valueIS7_EENSD_IPKcEEEEEEED0Ev]+0x3e): undefined reference to boost::detail::thread_data_base::~thread_data_base()' CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In functionboost::unit_test::make_test_case(boost::unit_test::callback0boost::unit_test::ut_detail::unused const&, boost::unit_test::basic_cstring)':
connection_pool.cpp:(.text.ZN5boost9unit_test14make_test_caseERKNS0_9callback0INS0_9ut_detail6unusedEEENS0_13basic_cstringIKcEE[ZN5boost9unit_test14make_test_caseERKNS0_9callback0INS0_9ut_detail6unusedEEENS0_13basic_cstringIKcEE]+0x13): undefined reference to boost::unit_test::ut_detail::normalize_test_case_name(boost::unit_test::basic_cstring<char const>)' connection_pool.cpp:(.text._ZN5boost9unit_test14make_test_caseERKNS0_9callback0INS0_9ut_detail6unusedEEENS0_13basic_cstringIKcEE[_ZN5boost9unit_test14make_test_caseERKNS0_9callback0INS0_9ut_detail6unusedEEENS0_13basic_cstringIKcEE]+0x3d): undefined reference toboost::unit_test::test_case::test_case(boost::unit_test::basic_cstring, boost::unit_test::callback0boost::unit_test::ut_detail::unused const&)'
CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In function _GLOBAL__sub_I__Z14init_unit_testv': connection_pool.cpp:(.text.startup+0x4d): undefined reference toboost::system::generic_category()'
connection_pool.cpp:(.text.startup+0x59): undefined reference to boost::system::generic_category()' connection_pool.cpp:(.text.startup+0x65): undefined reference toboost::system::system_category()'
connection_pool.cpp:(.text.startup+0xdd): undefined reference to boost::unit_test::ut_detail::auto_test_unit_registrar::auto_test_unit_registrar(boost::unit_test::test_case*, unsigned long)' connection_pool.cpp:(.text.startup+0x145): undefined reference toboost::unit_test::ut_detail::auto_test_unit_registrar::auto_test_unit_registrar(boost::unit_test::test_case
, unsigned long)'
connection_pool.cpp:(.text.startup+0x17d): undefined reference to vtable for boost::unit_test::unit_test_log_t' CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In functionmain':
connection_pool.cpp:(.text.startup+0xb): undefined reference to boost::unit_test::unit_test_main(bool (_)(), int, char*_)' CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In function boost::thread_exception::thread_exception(int, char const
)':
connection_pool.cpp:(.text._ZN5boost16thread_exceptionC2EiPKc[ZN5boost16thread_exceptionC5EiPKc]+0x14): undefined reference to boost::system::system_category()' CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In functionboost::condition_error::condition_error(int, char const)':
connection_pool.cpp:(.text._ZN5boost15condition_errorC2EiPKc[_ZN5boost15condition_errorC5EiPKc]+0x14): undefined reference to boost::system::system_category()' CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In functionboost::thread_group::~thread_group()':
connection_pool.cpp:(.text._ZN5boost12thread_groupD2Ev[_ZN5boost12thread_groupD5Ev]+0x1d): undefined reference to boost::thread::detach()' CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In functionboost::condition_variable::condition_variable()':
connection_pool.cpp:(.text._ZN5boost18condition_variableC2Ev[_ZN5boost18condition_variableC5Ev]+0x3d): undefined reference to boost::system::system_category()' CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In functionboost::thread::thread<boost::bi::bind_t<void, void ()(boost::shared_ptrredis3m::connection_pool, std::string const&), boost::_bi::list2boost::_bi::value<boost::shared_ptr<redis3m::connection_pool >, boost::_bi::value<char const*> > > >(boost::_bi::bind_t<void, void ()(boost::shared_ptrredis3m::connection_pool, std::string const&), boost::_bi::list2boost::_bi::value<boost::shared_ptr<redis3m::connection_pool >, boost::_bi::value<char const> > >, boost::disable_if_c<boost::thread_detail::is_convertible<boost::_bi::bind_t<void, void ()(boost::shared_ptrredis3m::connection_pool, std::string const&), boost::_bi::list2boost::_bi::value<boost::shared_ptr<redis3m::connection_pool >, boost::_bi::value<char const> > >&, boost::detail::thread_move_t<boost::bi::bind_t<void, void ()(boost::shared_ptrredis3m::connection_pool, std::string const&), boost::_bi::list2boost::_bi::value<boost::shared_ptr<redis3m::connection_pool >, boost::_bi::value<char const> > > > >::value, boost::thread::dummy>::type)':
connection_pool.cpp:(.text._ZN5boost6threadC2INS_3_bi6bind_tIvPFvNS_10shared_ptrIN7redis3m15connection_poolEEERKSsENS2_5list2INS2_5valueIS7_EENSD_IPKcEEEEEEEET_NS_12disable_if_cIXsrNS_13thread_detail14is_convertibleIRSK_NS_6detail13thread_move_tISK_EEEE5valueEPNS0_5dummyEE4typeE[_ZN5boost6threadC5INS_3_bi6bind_tIvPFvNS_10shared_ptrIN7redis3m15connection_poolEEERKSsENS2_5list2INS2_5valueIS7_EENSD_IPKcEEEEEEEET_NS_12disable_if_cIXsrNS_13thread_detail14is_convertibleIRSK_NS_6detail13thread_move_tISK_EEEE5valueEPNS0_5dummyEE4typeE]+0x54): undefined reference to vtable for boost::detail::thread_data_base' connection_pool.cpp:(.text._ZN5boost6threadC2INS_3_bi6bind_tIvPFvNS_10shared_ptrIN7redis3m15connection_poolEEERKSsENS2_5list2INS2_5valueIS7_EENSD_IPKcEEEEEEEET_NS_12disable_if_cIXsrNS_13thread_detail14is_convertibleIRSK_NS_6detail13thread_move_tISK_EEEE5valueEPNS0_5dummyEE4typeE[_ZN5boost6threadC5INS_3_bi6bind_tIvPFvNS_10shared_ptrIN7redis3m15connection_poolEEERKSsENS2_5list2INS2_5valueIS7_EENSD_IPKcEEEEEEEET_NS_12disable_if_cIXsrNS_13thread_detail14is_convertibleIRSK_NS_6detail13thread_move_tISK_EEEE5valueEPNS0_5dummyEE4typeE]+0x269): undefined reference toboost::thread::start_thread_noexcept()'
CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In function boost::condition_variable::wait(boost::unique_lock<boost::mutex>&)': connection_pool.cpp:(.text._ZN5boost18condition_variable4waitERNS_11unique_lockINS_5mutexEEE[_ZN5boost18condition_variable4waitERNS_11unique_lockINS_5mutexEEE]+0x15): undefined reference toboost::detail::get_current_thread_data()'
connection_pool.cpp:(.text._ZN5boost18condition_variable4waitERNS_11unique_lockINS_5mutexEEE[ZN5boost18condition_variable4waitERNS_11unique_lockINS_5mutexEEE]+0x78): undefined reference to boost::this_thread::interruption_point()' CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In functionboost::thread_group::add_thread(boost::thread)':
connection_pool.cpp:(.text._ZN5boost12thread_group10add_threadEPNS_6threadE[_ZN5boost12thread_group10add_threadEPNS_6threadE]+0x23): undefined reference to boost::this_thread::disable_interruption::disable_interruption()' connection_pool.cpp:(.text._ZN5boost12thread_group10add_threadEPNS_6threadE[_ZN5boost12thread_group10add_threadEPNS_6threadE]+0x89): undefined reference toboost::this_thread::disable_interruption::~disable_interruption()'
connection_pool.cpp:(.text._ZN5boost12thread_group10add_threadEPNS_6threadE[_ZN5boost12thread_group10add_threadEPNS_6threadE]+0xd9): undefined reference to boost::this_thread::disable_interruption::~disable_interruption()' CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o: In functionboost::thread_group::join_all()':
connection_pool.cpp:(.text._ZN5boost12thread_group8join_allEv[_ZN5boost12thread_group8join_allEv]+0x22): undefined reference to boost::this_thread::disable_interruption::disable_interruption()' connection_pool.cpp:(.text._ZN5boost12thread_group8join_allEv[_ZN5boost12thread_group8join_allEv]+0x7c): undefined reference toboost::this_thread::disable_interruption::~disable_interruption()'
connection_pool.cpp:(.text._ZN5boost12thread_group8join_allEv[_ZN5boost12thread_group8join_allEv]+0x9d): undefined reference to boost::thread::joinable() const' connection_pool.cpp:(.text._ZN5boost12thread_group8join_allEv[_ZN5boost12thread_group8join_allEv]+0xad): undefined reference toboost::thread::native_handle()'
connection_pool.cpp:(.text._ZN5boost12thread_group8join_allEv[_ZN5boost12thread_group8join_allEv]+0xc2): undefined reference to boost::thread::join_noexcept()' connection_pool.cpp:(.text._ZN5boost12thread_group8join_allEv[_ZN5boost12thread_group8join_allEv]+0x14f): undefined reference toboost::this_thread::disable_interruption::~disable_interruption()'
CMakeFiles/connection_pool_test.dir/tests/connection_pool.cpp.o:(.rodata._ZTIN5boost6detail11thread_dataINS_3_bi6bind_tIvPFvNS_10shared_ptrIN7redis3m15connection_poolEEERKSsENS2_5list2INS2_5valueIS7_EENSD_IPKcEEEEEEEE[_ZTIN5boost6detail11thread_dataINS_3_bi6bind_tIvPFvNS_10shared_ptrIN7redis3m15connection_poolEEERKSsENS2_5list2INS2_5valueIS7_EENSD_IPKcEEEEEEEE]+0x10): undefined reference to typeinfo for boost::detail::thread_data_base' libredis3m.so.2.0.0: undefined reference toboost::this_thread::hiden::sleep_until(timespec const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [connection_pool_test] Error 1
make[1]: *** [CMakeFiles/connection_pool_test.dir/all] Error 2
make: *** [all] Error 2

SET value with "-" is not able to go through

Hey,
I was trying to set a key value having "-" in it. But it doesn't work with reidis3m library.

Below command doesn't set a key-value pair in redis. However I am able to set this value using Redis-client.
connection->run(command("SET")<<"mykey"<<"myvalue-1");

CMake issue when compiling redis3m as submodule (use CMake add_subdirectory)

I use redis3m as git submodule in my project:

$ tree -L 1 ch1/
ch1/
├── build
├── CMakeCache.txt
├── CMakeFiles
├── cmake_install.cmake
├── CMakeLists.txt
├── gtest/
├── main.cc
├── Makefile
├── redis3m/
└── test

I add CMake add_subdirectory to compile redis3m:

add_subdirectory(redis3m)

Then I got the following error message:

[ 41%] Built target redis3m
make[2]: *** No rule to make target `Doxyfile', needed by `redis3m/docs'.  Stop.
make[1]: *** [redis3m/CMakeFiles/apidoc.dir/all] Error 2
make: *** [all] Error 2

I fix the error by changing CMAKE_SOURCE_DIR to CMAKE_CURRENT_SOURCE_DIR:

 FIND_PACKAGE(Doxygen QUIET)
 IF (DOXYGEN_FOUND)
-        SET(DOXYGEN_INPUT "${CMAKE_SOURCE_DIR}/Doxyfile")
+      SET(DOXYGEN_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile")
   SET(DOXYGEN_OUTPUT "docs")

I think CMAKE_CURRENT_SOURCE_DIR better than CMAKE_SOURCE_DIR when compiling redis3m in a project with multiple dependencies (When compiling redis3m alone, the two variable is same).

Error during make can't find hiredis.h

Hello,

When I'm attempting to build the package, the cmake works perfectly fine. When I run make however, it gets to about 17% then starts erroring hiredis/hiredis.h no such file or directory.

I've included all output from the git clone to the make in the following pastebin.

Thanks!! http://pastebin.com/XfxkdwW0

PS. I handbuilt this on a different system (worked fine) and it caused a DRASTIC reduction in wait times & greatly improved performance. So great job & thanks again.

Support building statically linked library

Hi, I was trying to get cmake to build a .a instead of a .so but I could not seem to be able to do it. However, it seems if you change the add_library call in CMakeLists.txt to:

add_library(${PROJECT_NAME} ${SRC_FILES} ${CMAKE_CURRENT_BINARY_DIR}/datadir.cpp ${INCLUDE_FILES})

(ie, remove SHARED), then the default behavior will still be to generate a shared library. But if you want a static library, you can run cmake -DBUILD_SHARED_LIBS:BOOL=OFF and then it will build a static library when running "make." Do you think this change is acceptable?

Usage of noncopyable and -Weffc++ warnings

Hi, would it be possible to make the code compile cleanly with -Weffc++? Most of the warnings come from not initializing all class members with initializer lists. However, some of the warnings are about noncopyable. Your implementation doesn't actually prevent anyone from making a copyable object since the deleted copy constructor and assignment operator are only protected, meaning they can still be overridden by derived classes. The only way that I can see to remove every one of the warnings would be to declare these two methods in your classes as "delete" explicitly, I can live with the "has pointer member but does not override..." warnings, as it may not be worth the effort of removing noncopyable entirely. However, it would be really nice if all of the warnings about uninitialized members could be addressed. I can also provide a PR for this, just try it out first with -Weffc++ and let me know what you want to do about noncopyable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.