Skip to main content

03 Memcache

Memcache is a free & open source, high-performance, distributed memory object caching system that works as key/value dictionary. It is generic in nature, intended for use in speeding up dynamic web applications by alleviating database load.

It is useful to store:

  • high demand (used often)
  • expensive results (hard to compute)
  • common (shared accross users)

It is implemented as a server which provides access over TCP or UDP and it follows these principles:

  • Fast network access (memcached servers close to other application servers)
  • No persistency (if your server goes down, data in memcached is gone)
  • No redundancy / fail-over
  • No replication (single item in cache lives on one server only)
  • No authentication (not in shared environments)
  • 1 key is maximum 1MB
  • keys are strings of 250 characters (in application typically MD5 of user readable string)
  • No enumeration of keys (thus no list of valid keys in cache at certain moment)
  • No active clean-up (only clean up when more space needed, LRU: Least Recently Used )

Memcache supports multiget which fetch multiple keys from memcached in one single call.