Class ActiveSupport::Cache::MemCacheStore
In: lib/active_support/cache/mem_cache_store.rb
Parent: Store

A cache store implementation which stores data in Memcached: www.danga.com/memcached/

This is currently the most popular cache store for production websites.

Special features:

  • Clustering and load balancing. One can specify multiple memcached servers, and MemCacheStore will load balance between all available servers. If a server goes down, then MemCacheStore will ignore it until it comes back up.

MemCacheStore implements the Strategy::LocalCache strategy which implements an in memory cache inside of a block.

Methods

build_mem_cache   clear   new   read_multi   stats  

Constants

ESCAPE_KEY_CHARS = /[\x00-\x20%\x7F-\xFF]/

Public Class methods

Creates a new MemCacheStore object, with the given memcached server addresses. Each address is either a host name, or a host-with-port string in the form of "host_name:port". For example:

  ActiveSupport::Cache::MemCacheStore.new("localhost", "server-downstairs.localnetwork:8229")

If no addresses are specified, then MemCacheStore will connect to localhost port 11211 (the default memcached port).

Instead of addresses one can pass in a MemCache-like object. For example:

  require 'memcached' # gem install memcached; uses C bindings to libmemcached
  ActiveSupport::Cache::MemCacheStore.new(Memcached::Rails.new("localhost:11211"))

Public Instance methods

Clear the entire cache on all memcached servers. This method should be used with care when shared cache is being used.

Reads multiple values from the cache using a single call to the servers for all keys. Options can be passed in the last argument.

Get the statistics from the memcached servers.

[Validate]