Memcached 教程

Memcached 是什么、与 Redis 的区别、以及这套教程怎么学。

Beginner
Key PointsMemcached 是高性能分布式内存缓存:纯键值、多线程、LRU 淘汰,专为加速动态应用而生。

Memcached 是什么

Memcached is a distributed in-memory object cache. Its only job: store arbitrary serializable values as key->value in RAM for high-speed reads, offloading the database. Born in 2003 at LiveJournal, it is the grandfather of caches.

与 Redis 怎么选

维度MemcachedRedis
数据结构纯字符串键值5+ 种丰富结构
线程模型多线程单线程(网络6.0多线程)
持久化无(纯内存)有 RDB/AOF
典型场景简单 KV 缓存、多核大容量缓存+队列+排行榜+锁

学习路线

  1. 装好并启动 memcached(监听 11211)
  2. 用 nc/telnet 连上,跑通存储命令
  3. 掌握 get / gets / delete / incr
  4. 看懂 stats,用 Java 客户端接入
Most new projects pick Redis for its richer feature set. Memcached still fits 'just a simple KV cache, max out multi-core RAM' cases with a tiny client. Default to Redis unless you have a specific reason.

Friends & Partners