-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redis object #3
Comments
By now, no such interface. Can you show me your complete code for constructing Also please tell me your gcc version, and hiredis version. Thanks! |
My dev environment is: Ubuntu 18.04.1 LTS \n \l, gcc version 7.3.0, with latest hiredis and Redis-plus-plus. I CANNOT reproduce your problem with the following code:
Since you get a bad_alloc problem, you might need to check if you still have enough memory to run your code. |
There's no such interface. The connection is lazily created. The constructor won't create a connection to Redis. Instead, only when the first time you send command with If it fails to connect to Redis or the connection is broken, it will throw an exception, i.e. |
Does that mean, using the same Redis object for sending stuff (i.e. redis.set()) will automatically reconnect to redis if connection failed (will redis.set() try to resume connection)? Thanks |
YES. When you call
YES, it's very expensive. You should NOT do that. Instead, you should create a
I'll add a specific exception class to distinguish connection broken error and other errors. |
Can I have a snippet of you makefile where you link libredis++ & libhiredis? I think I might have not correctly linked them. I know path will be different, but just want to double check in link everything needed. Thanks It's weird that no compile issue when only has sw::redis::Redis *redis = new sw::redis::Redis(config), but an error of undefined reference to redis->ping() occurred when adding redis->ping() for testing. Update: I keep getting undefined reference to `sw::redis::Redis::ping()' error. If removed Redis::ping() it compiled without error, but like I said it's still not linked correctly and that's probably why I got bad_alloc in the first place. |
You can show me your code, the path of the installed hiredis & redis++, and your makefile. So that I might figure out the problem. |
Also, do you remember which header files of your redis-plus-plus pull the hiredis's hiredis.h |
When compiling hiredis, the make install command will install all required headers. Check your install path. |
Hi @WeiChihChern , Have you solved the problem? Recently I found redis-plus-plus is NOT compatible with some old version hiredis. I've fixed the problem. Now the minimum version requirement for hiredis is v0.12.1. If you still have the problem, you can update redis-plus-plus and try again. Regards |
Somehow I just can't link your lib to my project. But, linking hiredis is working. Since I'm only using few functions from hiredis, I did my own implementation for it. Thank you for the assistance you have offered, appreciated! |
These days I CANNOT reproduce your problem with different gcc and clang versions on ubuntu, centos and macos. So I'll close the issue. However, if you want to retry redis-plus-plus in the future, you are always welcomed to reopen this issue :) |
Hello, is there any way of creating a sw::redis::Redis object without passing anything, and then connect the object to redis afterward?
sw::redis::Redis *redis = new sw::redis::Redis(config)
<- this run np on mac os with clang, but have bad_alloc issue on ubuntu with g++.Also, is there any way to check the connection result? Thank you.
The text was updated successfully, but these errors were encountered: