#include RedisProvider::RedisProvider() { setIp("127.0.0.1"); setPort(6379); setKey("DAQ_key"); } RedisProvider::RedisProvider(std::string ip, int port, std::string key) { setIp(ip); setPort(port); setKey(key); } int RedisProvider::write(BasePacket &packet) { redisReply *r = (redisReply *) redisCommand(context, "LPUSH %s %b","DAQ_key", (char *)packet.getBufferPtr(), (size_t) packet.getPacketSize()); if(r) return 1; return -1; } int RedisProvider::write(BasePacket &packet, std::string key) { redisReply *r = (redisReply *) redisCommand(context, "LPUSH %s %b",key, (char *)packet.getBufferPtr(), (size_t) packet.getPacketSize()); if(r) return 1; return -1; } int RedisProvider::open() { context = redisConnect(getIp().c_str(), getPort()); if (context == NULL || context->err) { if (context) { printf("Error: %s\n", context->errstr); } else { printf("Can't allocate Redis context\n"); } } return 1; } int RedisProvider::close() { std::cout << "Flushing..." << std::endl; return 1; } RedisProvider::~RedisProvider(){ std::cout << "Deleting Redis stream" << std::endl; }