Introduction to distributed cache BeIT Memcached

Source: Internet
Author: User
Tags server memory

Maybe you haven't used the distributed cache. In the case of a web Cluster, it can make some common data resident in the server memory without worrying about the non-synchronization of various web servers.
The following is a brief introduction to beitmemcached's support for. net. For more information, see
Http://code.google.com/p/beitmemcached/

A complete procedure:
1. Click downloads on the webpage to download the memcached_1.2.5.zip and beitmemcached_source_2008_05_31.zip packages.
2. Decompress memcached_1.2.5.zip, which is the server side of memcached.
3. Copy Memcached_1.2.5 to the computer you specified as the cache server, for example, 192.168.0.1.
4. Run the command 'd: \ memcached \ memcached.exe-d install' in cmd to install the server. At this time, it should appear in the windows service.
5. Run the command 'd: \ memcached \ memcached.exe-d start' in cmd to start the service and check whether the memcached process exists in the server process.
6. Check whether port 11211 of the server is enabled (in firewall settings). Otherwise, the server cannot be accessed by other machines.
7. The server has been installed and tested on other machines. Run cmd to telnet 192.168.0.1 11211 to check whether the server can log on.

8. Decompress beitmemcached_source_2008_05_31.zip. It is a client developed by. net 2.0. It contains all the source code and a call example.
9. Open the project with the corresponding version of vss. If you are interested, study the code slowly. If you are not interested, generate a class library and compile a BeITMemcached. dll file.
10. Create a console program, reference BeITMemcached. dll, and enter similar code for testing.

Using System; <br/> using BeIT. memCached; <br/> namespace ConsoleApplication3 <br/>{< br/> class Program <br/>{< br/> static void Main (string [] args) <br/>{< br/> MemcachedClient. setup ("TestCache", new string [] {"192.168.0.1"}); <br/> MemcachedClient cache = MemcachedClient. getInstance ("TestCache"); <br/> cache. sendReceieveTimeout = 5000; <br/> cache. minPoolSize = 1; <br/> cache. maxPoolSize = 5; <br/> cache. set ("jinjazz", "Scissors"); <br/> object obj = cache. get ("jinjazz"); <br/> Console. writeLine (obj); <br/> Console. read (); <br/>}< br/>}

A distributed cache example is as simple as operating hashtable.

11. Check the cache running status. You need to be familiar with some basic memcached commands.
Enter telnet 192.168.0.1 11211 on your machine to enter telnet
If stats is input, the following results will be displayed, and comments will be added to the comments that may be useful to you.
STAT pid 2928
Statuptime 139279
STAT time 1216258406
STAT version 1.2.5
STAT pointer_size 32
STAT curr_items 4
STAT total_items 6
STAT bytes 1052947
STAT curr_connections 2
STAT total_connections 10
STAT connection_structures 4
STAT performance_get 13 // read 13 times
STAT cmd_set 6 // set 6 times
STAT get_hits 11 // 11 hits
STAT get_misses 2 // 2 failures
STAT evictions 0
STAT bytes_read 1053321
STAT bytes_written 6279461
STAT limit_maxbytes 67108864
STAT threads 1
END

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.