12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <!--#
- Test type 2: Single database query
- TechEmpower Web Framework Benchmarks
- -->
- <!--#declaration
- #include "world.h"
- static char buffer[128];
- static UREDISClient_Base* rc;
- #ifndef AS_cpoll_cppsp_DO
- static UValue* pvalue;
- #endif
- static void usp_fork_rdb()
- {
- U_TRACE(5, "::usp_fork_rdb()")
- U_NEW(UREDISClient<UTCPSocket>, rc, UREDISClient<UTCPSocket>);
- if (rc->connect() == false)
- {
- U_WARNING("usp_fork_rdb(): %V", rc->UClient_Base::getResponse().rep);
- return;
- }
- u__memcpy(buffer, "world:", U_CONSTANT_SIZE("world:"), __PRETTY_FUNCTION__);
- #ifndef AS_cpoll_cppsp_DO
- U_NEW(UValue, pvalue, UValue(OBJECT_VALUE));
- #endif
- }
- #ifdef DEBUG
- static void usp_end_rdb()
- {
- U_TRACE(5, "::usp_end_rdb()")
- delete rc;
- #ifndef AS_cpoll_cppsp_DO
- if (pvalue) delete pvalue;
- #endif
- }
- #endif
- -->
- <!--#header
- Content-Type: application/json
- -->
- <!--#code
- uint32_t id;
- (void) rc->get(buffer, 6+u_num2str32(buffer+6, id = u_get_num_random(10000-1)));
- #ifdef AS_cpoll_cppsp_DO
- USP_PRINTF_ADD("{\"id\":%u,\"randomNumber\":%v}", id, rc->vitem[0].rep);
- #else
- UStringRep* rep = rc->vitem[0].rep;
- World world(id, u_strtoul(rep->data(), rep->end()));
- USP_JSON_stringify(*pvalue, World, world);
- pvalue->clear();
- #endif
- -->
|