During a big data test that includes services, you need to use a fast and large-capacity database. You can consider a relational database or a key-value cache database to create a cluster. LoadRunner: the C language has been completed. Today, I tried to operate Memcached in LoadRunner and use Libmemcached. First download the source code:Http://svn.coderepos.org/share/lang/c/libmemcached-win32 Then compile the code according to the instructions. the source code also contains the test code and sample code. There are three compilation methods: I. useCompile mingw32 and openVisual Studio Command Prompt: Cd libmemcached-latest/libmemcached Mingw32-make-f Makefile. w32 Cd ../cilents Mingw32-make-f Makefile. w32 Cd ../example Mingw32-make-f Makefile. w32 2. use Visual Studio 2005 or later to execute the compilation:Libmemcached-latest/visualc/libmemcached. sln 3. use nmake for compilation,OpenVisual Studio Command Prompt:Cd libmemcached-latest/libmemcached Nmake-f Makefile. msc Cd ../cilents Nmake-f Makefile. msc Cd ../example During nmake-f Makefile. msc compilation, memcached. dll is generated for the LoadRunner extension. For example: Source code: # Define SERVER_NAME "192.168.223.106" # Define SERVER_PORT 11211 Action () {// load libmemcached. dll first Int memc; Int rc; Int value_length = 0; Intf lags = 0; Int result; Long int num; Char * key = "name "; Char * value = "higkoo "; Char * discription = "Performance "; Memc = memcached_create (NULL ); Rc = memcached_server_add (memc, SERVER_NAME, SERVER_PORT ); Lr_output_message ("server add: % s/n", memcached_strerror (memc, rc )); Rc = memcached_set (memc, key, strlen (key), value, strlen (value), 0, 0 ); Lr_output_message ("set '% s' to' % s': % s/n", key, value, memcached_strerror (memc, rc )); Result = memcached_get (memc, key, strlen (key), & value_length, & flags, & rc ); Lr_output_message ("get '% s': % s/n", key, memcached_strerror (memc, rc )); Lr_output_message ("% s = % s/n", key, result ); Rc = memcached_behavior_set (memc, 0, 1 ); Lr_output_message ("behavior set to non-block: % s/n", memcached_strerror (memc, rc )); Result = memcached_get (memc, key, strlen (key), & value_length, & flags, & rc ); Lr_output_message ("get '% s': % s/n", key, memcached_strerror (memc, rc )); Lr_output_message ("% s = % s/n", key, value ); Rc = memcached_set (memc, key, strlen (key), discription, strlen (discription), 0, 0 ); Lr_output_message ("set '% s' to' % s': % s/n", key, discription, memcached_strerror (memc, rc )); Rc = memcached_increment (memc, key, strlen (key), 1, & num ); Lr_output_message ("incr '% s': % s/n", key, memcached_strerror (memc, rc )); Rc = memcached_increment (memc, key, strlen (key), 1, & num ); Lr_output_message ("incr '% s': % s/n", key, memcached_strerror (memc, rc )); Rc = memcached_increment (memc, key, strlen (key), 1, & num ); Lr_output_message ("incr '% s': % s/n", key, memcached_strerror (memc, rc )); Rc = memcached_decrement (memc, key, strlen (key), 1, & num ); Lr_output_message ("decr '% s': % s/n", key, memcached_strerror (memc, rc )); Result = memcached_get (memc, key, strlen (key), & value_length, & flags, & rc ); Lr_output_message ("get '% s': % s/n", key, memcached_strerror (memc, rc )); Lr_output_message ("test = % s/n", value ); Rc = memcached_delete (memc, key, strlen (key), 0 ); Lr_output_message ("delete '% s': % s/n", key, memcached_strerror (memc, rc )); Result = memcached_get (memc, key, strlen (key), & value_length, & flags, & rc ); Lr_output_message ("get (was deleted) '% s': % s/n", key, memcached_strerror (memc, rc )); Memcached_free (memc ); } ... |