Skip to content
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

Simple code does not work, set() throw an exception #158

Closed
patrickjchen opened this issue Feb 5, 2021 · 2 comments
Closed

Simple code does not work, set() throw an exception #158

patrickjchen opened this issue Feb 5, 2021 · 2 comments

Comments

@patrickjchen
Copy link

Hi, I like the C++ style, the features of the project. However I could not make the simplest code work on my machine (centos 7).
The call set() throw an exception:
A null status reply
Could you please help?
Thanks
---Patrick
int main()
{

try {
// Create an Redis object, which is movable but NOT copyable.
auto redis = Redis("tcp://127.0.0.1:6379");

// ***** STRING commands *****

redis.set("key", "val");  //exception is thrown here
std::cout << "Redis set key\n";
auto val = redis.get("key");    // val is of type OptionalString. See 'API Reference' section for details.
if (val) {
    // Dereference val to get the returned value of std::string type.
    std::cout << *val << std::endl;
}   // else key doesn't exist.
else
{
    std::cerr << "Key key does not exist\n";
}

} catch (const Error &e) {
// Error handling.
std::cerr << e.what() << "\n";
}
}

@sewenew
Copy link
Owner

sewenew commented Feb 6, 2021

@patrickjchen I cannot reproduce your problem with the latest code of hiredis and redis-plus-plus.

Please check if you have installed multiple versions of hiredis. If you do, you might get some wired problems. This and this are related issues.

Regards

@patrickjchen
Copy link
Author

Thank you @sewenew . Yes it's the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants