What is Memcached?
Memcached is a memory caching system.
The Memcached is a distributed memory object caching system. Even though Memcached is intended to speed up dynamic web applications, it is actually generic in nature. The Memcached improves the loading speed of dynamic database-driven websites efficiently. This is achieved by caching data and objects in RAM. It helps to reduce the number of times external data source (for example a database) must be read. The Memcached runs on all Unix-like operating systems that have at least Linux and OSX and also on Microsoft Windows. The software is free and open source. It is licensed under Revised BSD license. It works dependent on libevent library. The Memcached is useful and either the number of requests for a particular content is high or the cost of generating particular piece of content is high.
Memcached Installation
Memcached works on most of the Linux and BSD like systems. There are also windows builds available but no official support available for these build versions.
The software can be installed from a package same as other software. You can run the following command for Debian/Ubuntu:
# apt-get install memcached
and for Redhat/Fedora:
# yum install memcached
If you are using an OS which is of older version, the software available will be outdated. In such case, it is recommended to install the software from source code. When installing from the source code, you need to meet the dependency first. Memcached depends on libevent and you need to install this before proceeding with the compilation.
For Debian/Ubuntu:
# apt-get install libevent-dev
For Redhat/Fedora:
# yum install libevent-devel
Now you can move on installing the software
# wget https://memcached.org/latest
[you might need to rename the file]
# tar -zxf memcached-1.x.x.tar.gz
# cd memcached-1.x.x
# ./configure –prefix=/usr/local/memcached
# make && make test && sudo make install
You can view full configure options by running the command
# ./configure –help
These are the steps to install Memcached. The Memcached is actually a key/value store daemon. After you install it, the caching of data will not be done automatically. You need to program the applications to utilize the service. So, you need to install a client to use implement caching.
Memcached Process
Memcached APIs provide a very large hash table. This hash table can be distributed across multiple machines. When the table is full, subsequent inserts cause older data to be removed from the cache. This will be carried out in the least recently used order. Applications using Memcached typically layer requests and additions into RAM before falling back on a slower backing store like a database.
In the Memcached system, each item is made up of certain features. This involves a key, an expiration time, optional flags, and raw data. At the time of an item is requested, Memcached checks the expiration time to see if the item is still valid before returning the item to the client. The cache can be integrated with the application by ensuring that the cache is updated at the same time as the database. If the server runs out of memory, Memcached will look for the expired items to replace. If additional memory is needed after replacing all the expired items, Memcached replaces items that have not been requested for a certain length of time (the expiration timeout period or longer) and will try to keep more recently requested data in the memory.
The size of the hash table used in Memcached is often very large. It is limited to available memory across all the servers in the cluster of servers in a data center. Where high volume, wide audience web publishing requires it, this maybe as large as gigabytes. The Memcached consists of four fundamental components:
1) A client software. It receives a list of available Memcached servers.
2) A client-based hashing algorithm. This algorithm chooses a server based on the key input.
3) Server software, which stores the values with their keys into the internal hash table.
4) Server algorithms, which remove old data or reuse memory.
If you need any further assistance please contact our support department: info@appteam.it