コード例 #1
0
ファイル: testredis.c プロジェクト: qingwa1990/redis_command
void test_redis_hexists()
{
    redis_str_t key, filed1,filed2;
    redis_str_t *value = NULL;

    key.value = "author";
    key.value_len = strlen("author");

    filed1.value = "weixin";
    filed1.value_len = strlen("weixin");

    filed2.value = "name";
    filed2.value_len = strlen("name");
    
    int exists1 = -1, exists2 = -1;

    CU_ASSERT(redis_hexists(redis_pool, &key, &filed1, &exists1) == 0);
    CU_ASSERT(redis_hexists(redis_pool, &key, &filed1, &exists2) == 0);

    CU_ASSERT(exists1 == 0);
    CU_ASSERT(exists2 == 0);
}
コード例 #2
0
ファイル: hexists.c プロジェクト: roku6185/roku_redis
int main()
{
  return_code status;

  if((status = redis_connect("127.0.0.1", "6379")) == SUCCESS)
    printf("Connected.\n");
  else
  {
    printf("Connection failed.\n");
    return 1;
  }
  
  int response = -1;
  const char *key = "mykey";
  const char *field = "myfield";
  const char *value = "my test value";
  
  if(redis_hset(&response, key, field, value) == SUCCESS)
    printf("%s.%s=%s\n", key, field, value);
  
  if(redis_hexists(&response, key, field) == SUCCESS)
    printf("Exists %s.%s? %s\n", key, field, response > 0 ? "YES" : "NO");
  return 0;
}