A memcache overview
Memcached is a distributed cache system developed by LiveJournal's Brad Fitzpatrick, but is currently used by many Web sites. This is a set of open source code, released with BSD license authorization. Software is a high-performance distributed memory object caching system. By maintaining a huge hash table in memory for dynamic Web applications to ease the load on the database. Memcached is based on a hashmap that stores key/value pairs. Its daemon (daemon) is written in C, but the client can write in any language and communicate with the daemon through the memcached protocol. However, it does not provide redundancy (for example, copying its hashmap entries), and when a server s stops running or crashes, all key/value pairs placed on s will be lost.
Second, memcache working principle
Memcached is run as a daemon on one or more servers, receiving client connections and operations at any time.
Clients use various languages to write Php/java/c/c++/perl/python/ruby, etc.
1 Client issue request (1).
2 web/php responds to the client and checks whether the data requested by the user exists in the cache, and if so, simply returns the requested data (2,3,7) without requesting the database.
3 If the requested data is not found in the cache, then query the database. When the request data is returned, the data is stored in a cache (4,5,6,7).
Third, there are memcache and memcached differences:
In fact, Memcache is the name of this project, and Memcached is the main program file name on its server side.
Iv. Install the Memcache server (installed separately on Linux and Windows)
1. Download the memcached and libevent separately and put them in the/tmp directory:
# cd/tmp
# wget http://www.danga.com/memcached/dist/memcached-1.2.0.tar.gz
# wget http://www.monkey.org/~provos/libevent-1.2.tar.gz
2. Install Libevent First:
# tar ZXVF libevent-1.2.tar.gz
# CD libevent-1.2
#./configure--PREFIX=/USR
# make
# make Install
3. Test whether the Libevent is installed successfully:
# Ls-al/usr/lib | grep libevent
lrwxrwxrwx 1 root root 21 11?? 17:38 libevent-1.2.so.1-> libevent-1.2.so.1.0.3
-rwxr-xr-x 1 root root 263546 11?? 17:38 libevent-1.2.so.1.0.3
-rw-r--r--1 root root 454156 11?? 17:38 LIBEVENT.A
-rwxr-xr-x 1 root root 811 11?? 17:38 libevent.la
lrwxrwxrwx 1 root root 21 11?? 17:38 libevent.so-> libevent-1.2.so.1.0.3