Skip to content

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

Closed
@patrickjchen

Description

@patrickjchen

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";
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions