#include RedisProvider::RedisProvider() { setKey("DAQ_key"); this->stream = rediscpp::make_stream("localhost", "6379"); } RedisProvider::RedisProvider(std::string ip, int port, std::string key) { setKey(key); this->stream = rediscpp::make_stream(ip, std::to_string(port)); } int RedisProvider::write(BasePacket &packet) { auto response = rediscpp::execute(*stream, "set", getKey(), (char *) packet.getBufferPtr()); std::flush(*stream); return 1; } int RedisProvider::write(BasePacket &packet, std::string key) { return 1; } int RedisProvider::open() { try { auto response = rediscpp::execute(*stream, "ping"); std::cout << response.as() << std::endl; return 1; } catch (std::exception const &e) { std::cerr << "Redis Connection Error: " << e.what() << std::endl; return EXIT_FAILURE; } } int RedisProvider::close() { std::cout << "Flushing..." << std::endl; std::flush(*stream); return 1; } RedisProvider::~RedisProvider(){ std::cout << "Deleting Redis stream" << std::endl; }