Memcached Tutorial and It’s FAQ

What is memcache, how it is different from other caching tool. In this memcached tutorial i’ll try to cover frequently asked memcache questions.

What is memcached ?

MemcacheMemcached is a free , open source very popular in-memory caching system. It is one of the best caching tool for speeding up dynamic web applications by allevating database load. It stores the data in RAM so that it can served the data quickly.

How to Install Memcached

Why memcached is so popular

1. It’s free and open-source.

2. In-memory (Key-Value Pairs) data caching.

3. Great read and write performance.

4. Easy to implement and it’s API is available for almost all programming languages.

5. Data distribution to multiple servers.

6. Multithreaded.

** Important Points about Memcached

1. It’s a non-blocking server.

2. The value of key should not be greater than 1 MB. So if i am setting the key product, then the value stored in product key is not greater than 1 MB.

Memcached Storage Commands.

a) get – Retrieve value based on key.
b) set – used to set the data.
c) add – stores data if not exists.
d) replace – Replace existing data.
e) delete – Remove an item from the cache.

Memcached Frequently Asked Questions

1. Is data stored in memcached is available if server is shut down or restarted.

No. Data stored in memcached is not durable so if server is shut down or restarted then all the data stored in memcache is deleted.

2. What happens when memory allocated to memcache is full ?

It implements LRU (Least recently used) algorithm. So when memory allocated memory is full in that case the oldest and least recently accessed data is replaced with newer data(key-value pair).

3. How to create connection with Memcached Server.

First you need to install memcached on your server. After that

If you are using multiple memcached servers then,

4. PHP Application with Memcached

Recommended Books

Getting Started with Memcached

Conclusion

For further reading on this topic, follow the links

PHP Client Comparison

PHP.Net Manual

Tagged , , , . Bookmark the permalink.

About WebRewrite

I am technology lover who loves to keep updated with latest technology. My interest field is Web Development.