//redis get set
TEST_F(Gtest, test_Redis_GS) {
	std::string name = "因两";
	Redis *r = new Redis();
	if (!r->connect("localhost", 6379)) {
		printf("connect error!\n");
	}
	r->set("name", name);
	printf("Get the name is %s\n", r->get("name"));

	EXPECT_EQ(name, r->get("name"));
}
Exemple #2
0
static int ntop_get_redis(lua_State* vm) {
  char *key, rsp[4096];
  Redis *redis = ntop->getRedis();

  if(ntop_lua_check(vm, __FUNCTION__, 1, LUA_TSTRING)) return(CONST_LUA_ERROR);
  if((key = (char*)lua_tostring(vm, 1)) == NULL)       return(CONST_LUA_PARAM_ERROR);

  lua_pushfstring(vm, "%s", (redis->get(key, rsp, sizeof(rsp)) == 0) ? rsp : (char*)"");

  return(CONST_LUA_OK);
}
int main1() {
	Redis *r = new Redis();
	if (!r->connect("localhost", 6379)) {
		printf("connect error!\n");
		return 0;
	}
	r->set("name", "因两");
	printf("Get the name is %s\n", r->get("name"));
	delete r;
	return 0;
}