LoadRunner uses Libmemcached to communicate with Memcached _ MySQL

Source: Internet
Author: User
[Switch] LoadRunner uses Libmemcached to communicate with Memcached

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. use‍Compile mingw32 and open‍Visual 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,‍Open‍Visual 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 );
}

...

Green channel: please follow my favorites to contact me

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.