memcachedをWindows Web Server 2008にインストールする.
スキルチャージプログラムなサーバーにmemcachedをインストールしてみる.
Windows Web Server 2008は,名前のとおりWindowsなので,Windowsバイナリをダウンロードしてくる.
既に上記ページにインストール方法が書いてあるので,ちょっと訳してみる.
Windowsなのでサービスインストールする必要がある.
- Unzip the binaries in your desired directory (eg. c:\memcached)
- Install the service using the command: 'c:\memcached\memcached.exe -d install' from either the command line
- Start the server from the Microsoft Management Console or by running the following command: 'c:\memcached\memcached.exe -d start'
- Use the server, by default listening to port 11211
特に難しいことはなさげ.
この通りにインストールしてみる.
まずはダウンロード.
ダウンロードしてきたファイルを
に展開してみた.んで
c:\Program Files (x86)\memcached-1.2.1-win32\memcached.exe -d install
でインストール.さらに
c:\Program Files (x86)\memcached-1.2.1-win32\memcached.exe -d start
でサービス開始なのですよ.
動いていることを確認する.
Rubyで使いたかったので,Rubyで書く書く.
とりあえずmemcacheをRequireしなくちゃいけないらしいので
gem install memcache-client
と実行してみる.
それからいざ,Rubyのコードを書きます.
memcachedに追加する場合.
require "memcache"
cache = MemCache::new 'localhost:11211'
cache["robot"] = "Iroha Liner"
cache["college"] = "Oyama"
読み込む場合
require "memcache"
cache = MemCache::new 'localhost:11211'
puts cache["robot"]
puts cache["college"]
ほんと超簡単.
memcachedとmemcache-clientに感謝!