mac osxにmemcachedをインストール。
$ sudo port install memcached Password: ---> Fetching libevent ---> Attempting to fetch libevent-1.4.3-stable.tar.gz from http://monkey.org/~provos/ ---> Verifying checksum(s) for libevent ---> Extracting libevent ---> Configuring libevent ---> Building libevent with target all ---> Staging libevent into destroot ---> Installing libevent 1.4.3_0 ---> Activating libevent 1.4.3_0 ---> Cleaning libevent ---> Fetching memcached ---> Attempting to fetch memcached-1.2.5.tar.gz from http://www.danga.com/memcached/dist/ ---> Verifying checksum(s) for memcached ---> Extracting memcached ---> Configuring memcached ---> Building memcached with target all ---> Staging memcached into destroot ---> Creating launchd control script ########################################################### # A startup item has been generated that will aid in # starting memcached with launchd. It is disabled # by default. Execute the following command to start it, # and to cause it to launch at startup: # # sudo launchctl load -w /Library/LaunchDaemons/org.macports.memcached.plist ########################################################### ---> Installing memcached 1.2.5_2 ---> Activating memcached 1.2.5_2 ---> Cleaning memcached
memcachedの自動起動を設定。
$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.memcached.plist
cached_modelをインストール。(memcache-clientもインストールされる。)
$ sudo gem install cached_model
config/environment.rb
require 'memcache' memcache_options = { :c_threshold => 10_000, :compression => true, :debug => false, :namespace => ":app-#{RAILS_ENV}", :readonly => false, :urlencode => false } CACHE = MemCache.new memcache_options CACHE.servers = 'localhost:11211' ActionController::Base.session_options[:expires] = 1800 ActionController::Base.session_options[:cache] = CACHE
参考:
memcached Basics for Rails | Ruby on Rails for Newbies
memcached: a distributed memory object caching system
memcached公式サイト
Installing memcached | Development, Analysis And Research
memcahcedのインストール方法
Rails fragment cache with memcached-client and time-based :expire option - skwpspace
railsのfragment cacheでmemcachedを使うためのプラグイン
railsのセッション管理でmemcachedを利用 - dreammindの日記
FFTT : memcached
[memcached] memcached導入手順 - Life with IT