Optimize web applications with Memcached


High-performance, distributed memory object caching system which is free & open source, is Our MEMCACHED where it helps in speeding up the dynamic web applications by alleviating database load.

Deals with in-memory key-value where memcache stores for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.

Memcached is simple yet powerful. Its simple design promotes quick deployment, ease of development, and solves many problems facing large data caches. Its API is available for most popular languages.


Deployments of Memcached lay within trusted networks where clients can freely connect to any server.However, at –times Memcached is deployed in untrusted networks or where administrators want to exercise control over the clients that are connecting. During this latency Memcached can be compiled with optional SASL authentication support. The SASL support requires the binary protocol.

Memcached offers advantages

  • Direct access to the storage engine avoids the parsing and planning overhead of SQL.
  • Running memcached in the same process space as the MySQL server avoids the network overhead of passing requests back and forth.
  • Data written using the memcached protocol is transparently written to a DB table, without going through the MySQL SQL layer. You can control frequency of writes to achieve higher raw performance when updating non-critical data.
  • Data requested through the memcached protocol is transparently queried from a DB table, without going through the MySQL SQL layer.
  • Subsequent requests for the same data are served from the DB buffer pool. The buffer pool handles the in-memory caching. You can tune performance of data-intensive operations using DB configuration options.
  • Data can be unstructured or structured, depending on the type of application. You can create a new table for data, or use existing tables.
  • The transfer between memory and disk is handled automatically, simplifying application logic.
  • You can access the underlying DB table through SQL for reporting, analysis, ad hoc queries, bulk loading, multi-step transactional computations, set operations such as union and intersection, and other operations suited to the expressiveness and flexibility of SQL.
  • The serialization features of memcached, which can turn complex data structures, binary files, or even code blocks into storable strings, offer a simple way to get such objects into a database.
  • You do not need to manually load data into memcached at startup. As particular keys are requested by an application, values are retrieved from the database automatically, and cached in memory using the DB buffer pool.
  • Because memcached consumes relatively little CPU, and its memory footprint is easy to control, it can run comfortably alongside a MySQL instance on the same system.
  • Because data consistency is enforced by mechanisms used for regular DB tables, you do not have to worry about stale memcached data or fallback logic to query the database in the case of a missing key.

Sample Snippet :

Converting database or object creation queries to use Memcached is simple. Typically, when using straight database queries, example code would be as follows:

function get_foo(int userid)

data = db_select(“SELECT * FROM users WHERE userid = ?”, userid)

return data

After conversion to Memcached, the same call might look like the following

function get_foo(int userid)

/* first try the cache */

data = memcached_fetch(“userrow:” + userid)

if not data

/* not found : request database */

data = db_select(“SELECT * FROM users WHERE userid = ?”, userid)

/* then store in cache until next get */

memcached_add(“userrow:” + userid, data)

return data



Leave a Reply

Your email address will not be published. Required fields are marked *

we accept payment through

Social Media Auto Publish Powered By : XYZScripts.com