memcached Installation and command usage under Windows

Source: Internet
Author: User
Tags cas

: http://blog.couchbase.com/memcached-windows-64-bit-pre-release-available

Click on the red circle:

Unzip after download, such as extract to memcached folder in D drive
Open start-up run-->cmd call the command window and use the command to enter the memcached directory
Install memcached: Enter D:\memcached\memcached.exe-d install, after installation
Start memcached Service: Enter "D:\memcached\memcached.exe-d start" to start the service


This memcached becomes the Windows service.
If you need to turn off the memcached service, enter:
D:\memcached\memcached.exe-d Stop|shutdown to close.
Setting memcached, when the service is started, the memcached service defaults to a port of 11211, and the maximum memory consumed by default is 64M.
If you need to modify both parameters, such as modifying the port to 10000 and memory at 512, enter:
D:\memcached\memcached.exe-p 10000-m 512-d Start,-p indicates the port to be modified, and-m represents the maximum memory used (in M).
Common commands: 1.telnet to Memcache server, such as: Telnet 192.168.1.120 11211 (11211 is the default port for Memcache)


Set: Used to add a new key-value pair to the cache. If the key already exists, the previous value will be replaced.
Add: The Add command adds a key-value pair to the cache only if the key does not exist in the cache. If the key already exists in the cache, the previous value will remain the same, and you will get a response of not_stored.
Replace: The Replace command replaces the key in the cache only if the key already exists. If the key does not exist in the cache, you will receive a not_stored response from the memcached server.
Get: Used to retrieve the value associated with the previously added key-value pair.
Delete: Used to delete any existing values in the memcached. You will use a key to call Delete, and if the key exists in the cache, delete the value. If it does not exist, a NOT_FOUND message is returned.
Gets: Features similar to the basic get command. The difference between the two commands is that gets returns slightly more information: the 64-bit integer value is very much like the "version" identifier of a name/value pair.
The first three commands are standard modification commands for manipulating key-value pairs stored in memcached. They are both very easy to use and are all using the syntax shown in Listing 5:

Command <key> <flags> <expiration time> <bytes>
<value>

Table 1. Memcached Modifying command parameters

Parameter usage
Key key to find cached values
Flags can include integer parameters for key-value pairs, which the client uses to store additional information about key-value pairs
Expiration time (in seconds, 0 for forever) when a key-value pair is saved in the cache
Bytes The byte points stored in the cache
Value stored values (always in the second row) example:
Set Useid 0 0 5

1234



4. Cache Management Commands

The last two memcached commands are used to monitor and clean memcached instances. They are stats and Flush_all commands.

Stats: Dumps the current statistics for the connected memcached instance.
Flush_all: Used to clean up all name/value pairs in the cache. If you need to reset the cache to a clean state, flush_all can be of great use.
To view the basic commands for the memcached status, this command allows you to see the following information:

STAT PID 22459 Process ID
STAT uptime 1027046 server running seconds
STAT time 1273043062 Server current UNIX timestamp
STAT version 1.4.4 Server version
STAT pointer_size 64 OS Word size (this server is 64-bit)
STAT rusage_user 0.040000 Process Cumulative User Time
STAT rusage_system 0.260000 Process Cumulative system time
STAT curr_connections 10 Number of currently open connections
STAT total_connections 82 Total connections that were opened
STAT connection_structures 13 Number of connection structures allocated by the server
STAT cmd_get 54 Execute Get Command Total
STAT Cmd_set 34 Execute SET command total
STAT Cmd_flush 3 points to the total number of FLUSH_ALL commands
STAT get_hits 9 Get hit count
STAT get_misses number of Get misses
STAT delete_misses 5 Delete misses
STAT delete_hits 1 Delete hit count
STAT incr_misses 0 incr number of misses
STAT incr_hits 0 incr hit count
STAT decr_misses 0 decr number of misses
STAT decr_hits 0 DECR hit count
STAT cas_misses 0 CAs misses
STAT cas_hits 0 CAs hit count
STAT Cas_badval 0 Use wipe count
STAT Auth_cmds 0
STAT auth_errors 0
STAT bytes_read 15785 Read Bytes total
STAT bytes_written 15222 Write Bytes Total
STAT limit_maxbytes 1048576 Allocated memory number (bytes)
STAT Accepting_conns 1 Number of links currently accepted
STAT Listen_disabled_num 0
STAT Threads 4 Thread Count
STAT Conn_yields 0
STAT bytes 0 Stores the item byte number
STAT Curr_items 0 Item number
STAT total_items Total number of item
STAT evictions 0 To get the total amount of space deleted item

Download the. NET client:

Manage NuGet Package Search memcached, select Install memcached Client,

C # Client Test code:

 private static void Main (string[] args) {string[] serverlist = {"192.168.1.120:11211"};            Initialize pool Sockiopool pond = sockiopool.getinstance (); Pool.            Setservers (serverlist); Pool.            Initconnections = 3; Pool.            Minconnections = 3; Pool.            MaxConnections = 5; Pool.            socketconnecttimeout = 1000; Pool.            Sockettimeout = 3000; Pool.            Maintenancesleep = 30; Pool.            Failover = true; Pool.            Nagle = false; Pool.            Initialize ();            Get the client instance memcachedclient mc = new Memcachedclient (); Mc.            EnableCompression = false;            Console.WriteLine ("------------Test-----------"); Mc. Set ("Test", "my Value"); Stores the data to the cache server, where the string "My value" is cached, and the key is "test" if (MC.                Keyexists ("test"))//test cache exists key test for project {Console.WriteLine ("Test is Exists"); Console.WriteLine (MC. Get ("Test"). ToString ()); Get in cacheItem with key test} else {Console.WriteLine ("Test Not Exists"); }}

  

memcached Installation and command usage under Windows

Related Article

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.