Skip to content
Redis_Provider.h 966 B
Newer Older
Valerio Pastore's avatar
Valerio Pastore committed
/*
 *
 *  Created on: Mar 1, 2021
 *      Author: astrisw
 */

#ifndef REDISPROVIDER_H_
#define REDISPROVIDER_H_

#include <Base_Provider.h>
#include <unordered_map>
Valerio Pastore's avatar
Valerio Pastore committed
#include <hiredis.h>
Valerio Pastore's avatar
Valerio Pastore committed

Valerio Pastore's avatar
Valerio Pastore committed
namespace inaf::oasbo::Providers {
Valerio Pastore's avatar
Valerio Pastore committed

class RedisProvider : public BaseProvider{
private:
Valerio Pastore's avatar
Valerio Pastore committed
	redisContext *context;
Valerio Pastore's avatar
Valerio Pastore committed
	std::string ip;
Valerio Pastore's avatar
Valerio Pastore committed
	int port;
Valerio Pastore's avatar
Valerio Pastore committed
	std::string & key = *(&this->dest);

	void setDest(std::string dest){setKey(dest);}
	std::string getDest(){return getKey();}


public:
	RedisProvider();
Valerio Pastore's avatar
Valerio Pastore committed
	RedisProvider(std::string ip, int port, std::string key);
Valerio Pastore's avatar
Valerio Pastore committed

	void setIp(std::string ip){this->ip=ip;}
Valerio Pastore's avatar
Valerio Pastore committed
	void setPort(int port){this->port=port;}
Valerio Pastore's avatar
Valerio Pastore committed
	void setKey(std::string key){this->key=key;}


	std::string getIp(){return this->ip;}
Valerio Pastore's avatar
Valerio Pastore committed
	int getPort(){return this->port;}
Valerio Pastore's avatar
Valerio Pastore committed
	std::string getKey(){return this->key;}
Valerio Pastore's avatar
Valerio Pastore committed


Valerio Pastore's avatar
Valerio Pastore committed
	int write(PacketLib::BasePacket &);
	int write(PacketLib::BasePacket &, std::string dest);
Valerio Pastore's avatar
Valerio Pastore committed
	int close();
	int open();
Valerio Pastore's avatar
Valerio Pastore committed
	~RedisProvider();
Valerio Pastore's avatar
Valerio Pastore committed

};
Valerio Pastore's avatar
Valerio Pastore committed
}
Valerio Pastore's avatar
Valerio Pastore committed
#endif /* REDISPROVIDER_H_ */