rdb.usp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <!--#
  2. Test type 2: Single database query
  3. TechEmpower Web Framework Benchmarks
  4. -->
  5. <!--#declaration
  6. #include "world.h"
  7. static char buffer[128];
  8. static char* ptr = buffer+6;
  9. static UREDISClient_Base* rc;
  10. static void usp_fork_rdb()
  11. {
  12. U_TRACE(5, "::usp_fork_rdb()")
  13. U_NEW(UREDISClient<UTCPSocket>, rc, UREDISClient<UTCPSocket>);
  14. if (rc->connect() == false)
  15. {
  16. U_WARNING("usp_fork_rdb(): %V", rc->UClient_Base::getResponse().rep);
  17. delete rc;
  18. rc = U_NULLPTR;
  19. return;
  20. }
  21. U_MEMCPY(buffer, "world:", U_CONSTANT_SIZE("world:"));
  22. }
  23. #ifdef DEBUG
  24. static void usp_end_rdb()
  25. {
  26. U_TRACE(5, "::usp_end_rdb()")
  27. if (rc) delete rc;
  28. }
  29. #endif
  30. -->
  31. <!--#header
  32. Content-Type: application/json
  33. -->
  34. <!--#code
  35. uint32_t id;
  36. (void) rc->get(buffer, 6+u_num2str32(id = u_get_num_random(10000-1), ptr)-ptr);
  37. #ifdef AS_cpoll_cppsp_DO
  38. USP_PRINTF_ADD("{\"id\":%u,\"randomNumber\":%v}", id, rc->vitem[0].rep);
  39. #else
  40. World world(id, rc->vitem[0].strtoul());
  41. USP_OBJ_JSON_stringify(world);
  42. #endif
  43. -->