Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation and basic usage of Linux memcache

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article shares with you about the installation and basic usage of Linux memcache. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.

Memcache is a distributed cache system characterized by key-value storage

First, when compiling and installing memcache and redis in linux, you need gcc,make,cmake,autoconf,libtool and other tools, and you can install them directly using yum:

Yum install gcc make cmake autoconf libtool

Download the official source code:

Memcached depends on the libevent library, so you need to install libevent first, download address: http://libevent.org/

Download address of memcache official website: http://memcached.org/

Cd usrlocalgithub.comlibeventlibeventreleasesdownloadrelease.stablelibevent.www.memcached.orgfilesmemcached..tar.gz

3. Install libevent dependency and memcache:

Tar zxvf libevent-2.0.21-stable.tar.gzcd libevent-2.0.21-stable./configure-- prefix=/usr/local/libevent make & & make installcd.. tar zxvf memcached-1.4.5.tag.gzcd memcached-1.4.5./configure-- prefix=/usr/local/memcached-- with-libevent=/usr/local/libeventmake & & make installtar zxvf memcached-1.4.5.tag.gz

Cd memcached-1.4.5

. / configure-prefix=/usr/local/memcached-with-libevent=/usr/local/libevent

Make & & make install

Note that if an error is reported during the configure process, the library is usually missing. After installation, you will see the memcached directory in the / usr/local directory and start memcache:

Cd / usr/local/memcachedbin/memcached-m 64-p 11211-u root-vv #-m 64: maximum memory allocated to memcached, default is 64mb-p 11211: listening port number-u root: user running memcache

After the startup is successful, you will see the following figure:

Note that if you want memcache to run as a service background, you need to add-d:

Bin/memcached-m 64-p 11211-u root-d

4. Link the server memcache under windows:

The memcache of the dos window link server in the windows system needs to use the telnet function, which is included with windows, but needs to be manually turned on. Control panel-programs-turn on or off the windows function:

Check the confirmation box for the telnet client and enter the command in the dos window:

Telnet 192.168.1.1 11211 # ip replace your server ip 11211 with the listening port number of memcache

After connecting, you will see an all-black window with a flashing cursor. Use the shortcut key: Ctrl +] and then enter, and then you can use the add, delete, modify and search command of memcache.

5: add, delete, change and check memcache. Enter enter the value after entering the add, delete, change and search command for unified operation, and then enter to complete the execution:

Add key flag expire length # add key: for the specified key flag: identify expire: for valid time length: for length

The new key is name, marked as 0, and the valid time does not expire automatically (setting a specific value such as 10 means 10 seconds of expiration, setting it to 0 is not exact, but it will not automatically fail. If you restart the server, it will definitely fail), with a length of 5 bytes.

Get key # query key: for the specified key

Returned the newly added name record above

Delete key [time seconds] # Delete the specified key. If you add the optional parameter time, it means that get,add,replace is not allowed to operate this key within time seconds after deleting the key.

Delete and then query. There is no such record.

Replace key flag expire length # replacement, like add, can be replaced with replace only for keys that already exist

Add qwe= > 12345 replace replace with 54321, and then get the get

Set key flag expire length # sets or modifies parameters the same as replace, but the function is different. If the key does not exist in set, it will be added if the test modification already exists.

The URL key does not exist. Set url= > lnamp get again. Query the record, where set plays a new role.

Incr # increase the specified value

Age is 25, incr 5 is 30.

Decr # reduces the specified value

The above age is 30, minus 8 returns 22

Stats # counts the currently running memcache information

Flush_all # clear all storage objects. Thank you for reading! On the installation of Linux memcache and the basic use of sharing here, I hope that the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report