Apsaradb for Memcache is a temporary key-value storage NoSQL database. In the past, it was widely used on Internet websites as a cache layer between applications and databases (it has been replaced by Redis ), it was initially developed by Danga Interactive to speed up LiveJournal access, and later became an open source project widely used, Official Website: http://memcached.org/
Memcache features
- Full Memory Operation
- Hash Storage
- Simple text protocol for data communication
- Operations on bytes data. Other types of data are explained by the application and support serialization and deserialization.
- The cluster is also controlled by the application and adopts the consistent hash algorithm.
Install and start Memcache:
[root@lx61 ~]# yum install memcached
Start:
[root@lx61 ~]# /etc/init.d/memcached startStarting memcached: [ OK ]
The default listener port is 11211:
[root@lx61 ~]# ps -ef|grep memcache101 21341 1 0 13:38 ? 00:00:00 memcached -d -p 11211 -u memcached -m 64 -c 1024 -P /var/run/memcached/memcached.pid
Memcache acts as the database cache
Memcache is mainly used as a database cache. When it is used as a database cache, the process for applications to access the database is as follows:
1) before accessing the database, check whether the key in memcache is the SQL statement.
2) If yes, use its value as the query result, which can reduce the access pressure on the database.
3) If no, access the database and put the retrieved results (value) and corresponding SQL statement (key) into memcached.
High Availability solution-repcached
/Usr/local/bin/repcached-p 11211-v
/Usr/local/bin/repcached-p 11212-x localhost-v-d
Do not run as root