bool TestExtMemcached::test_Memcached_cas() {
  CREATE_MEMCACHED();
  for (ArrayIter iter(memc_version); iter; ++iter) {
    if (!f_version_compare(iter.second().toString(), "1.3.0", ">=")) {
      SKIP("Need memcached 1.3.0 for CAS");
      return Count(true);
    }
  }

  const char *key = "cas_test";

  VERIFY(memc->t_set(key, 10, EXPIRATION));

  Variant cas;

  VS(memc->t_get(key, null, strongBind(cas)), 10);

  VERIFY(!cas.isNull() && cas.isDouble());
  VERIFY(memc->t_cas(cas.toDouble(), key, 11, EXPIRATION));

  VS(memc->t_get(key, null, cas), 11);
  VERIFY(!memc->t_cas(cas.toDouble(), key, 12, EXPIRATION));
  VS(memc->t_get(key, null, cas), 11);

  return Count(true);
}
bool TestExtMemcached::test_Memcached_delete() {
  CREATE_MEMCACHED();
  const char *key = "delete_test";
  VERIFY(memc->t_set(key, "foo", EXPIRATION));
  VERIFY(memc->t_delete(key));
  VS(memc->t_get(key), false);

  return Count(true);
}
bool TestExtMemcached::test_Memcached_get_set() {
  CREATE_MEMCACHED();

  const char *key = "foo";
  Array value = CREATE_MAP1("foo", "bar");
  memc->t_set(key, value, EXPIRATION);
  VS(memc->t_get(key), value);

  return Count(true);
}
bool TestExtMemcached::test_Memcached_types() {
  Array list;
  list.add("boolean_true", true);
  list.add("boolean_false", false);
  list.add("string", "just a string");
  list.add("string_empty", "");
  list.add("integer_positive_integer", 10);
  list.add("integer_negative_integer", -10);
  list.add("integer_zero_integer", 0);
  list.add("float_positive1", 3.912131);
  list.add("float_positive2", 1.2131E+52);
  list.add("float_negative", -42.123312);
  list.add("float_zero", 0.0);
  list.add("null", null);
  list.add("array_empty", Array());
  list.add("array", CREATE_VECTOR4(1, 2, 3, "foo"));

  CREATE_MEMCACHED();
  for (ArrayIter iter(list); iter; ++iter) {
    VERIFY(memc->t_set(iter.first(), iter.second(), EXPIRATION));
    VS(memc->t_get(iter.first()), iter.second());
  }

  for (ArrayIter iter(list); iter; ++iter) {
    VERIFY(memc->t_delete(iter.first()));
  }

  VERIFY(memc->t_setmulti(list, EXPIRATION));
  Variant res = memc->t_getmulti(list.keys());
  VERIFY(res.isArray());
  Array resArray = res.toArray();
  VERIFY(resArray->size() == list.size());
  for (ArrayIter iter(resArray); iter; ++iter) {
    VS(iter.second(), list[iter.first()]);
  }

  return Count(true);
}
Beispiel #5
0
bool TestExtMemcached::test_Memcached_types() {
  Array list;
  list.add(s_boolean_true, true);
  list.add(s_boolean_false, false);
  list.add(s_string, "just a string");
  list.add(s_string_empty, empty_string);
  list.add(s_integer_positive_integer, 10);
  list.add(s_integer_negative_integer, -10);
  list.add(s_integer_zero_integer, 0);
  list.add(s_float_positive1, 3.912131);
  list.add(s_float_positive2, 1.2131E+52);
  list.add(s_float_negative, -42.123312);
  list.add(s_float_zero, 0.0);
  list.add(s_null, uninit_null());
  list.add(s_array_empty, Array());
  list.add(s_array, make_packed_array(1, 2, 3, "foo"));

  CREATE_MEMCACHED();
  for (ArrayIter iter(list); iter; ++iter) {
    VERIFY(memc->t_set(iter.first(), iter.second(), EXPIRATION));
    VS(memc->t_get(iter.first()), iter.second());
  }

  for (ArrayIter iter(list); iter; ++iter) {
    VERIFY(memc->t_delete(iter.first()));
  }

  VERIFY(memc->t_setmulti(list, EXPIRATION));
  Variant res = memc->t_getmulti(f_array_keys(list).toArray());
  VERIFY(res.isArray());
  Array resArray = res.toArray();
  VERIFY(resArray->size() == list.size());
  for (ArrayIter iter(resArray); iter; ++iter) {
    VS(iter.second(), list[iter.first()]);
  }

  return Count(true);
}