-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ze Gan <[email protected]>
- Loading branch information
Showing
8 changed files
with
88 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "redisstring.h" | ||
#include <hiredis/hiredis.h> | ||
|
||
namespace swss { | ||
|
||
RedisString::RedisString() | ||
: m_data(nullptr), | ||
m_len(0) | ||
{ | ||
} | ||
|
||
RedisString::~RedisString() | ||
{ | ||
reset(); | ||
} | ||
|
||
void RedisString::reset(char *str, int len) | ||
{ | ||
if (m_data != nullptr) | ||
{ | ||
redisFreeCommand(m_data); | ||
} | ||
m_data = str; | ||
m_len = len; | ||
} | ||
|
||
const char *RedisString::getStr() const | ||
{ | ||
return m_data; | ||
} | ||
|
||
int RedisString::getLen() const | ||
{ | ||
return m_len; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
namespace swss { | ||
|
||
class RedisString { | ||
public: | ||
|
||
RedisString(); | ||
|
||
~RedisString(); | ||
|
||
void reset(char *str = nullptr, int len = 0); | ||
|
||
const char *getStr() const; | ||
|
||
int getLen() const; | ||
|
||
private: | ||
char *m_data; | ||
int m_len; | ||
}; | ||
|
||
} |