2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

play2.0 on herokuでmemcachedを使う

Posted at

ぐぐらなくても雰囲気でできるレベル。herokuまたは俺すごい。

%brew install memcached
%memcached -vv
%heroku addons:add memcache:5mb//自分はherokuのGUIからインストールした
%heroku config
MEMCACHE_PASSWORD   => password
MEMCACHE_SERVERS    => server
MEMCACHE_USERNAME   => user_name
myproject/conf/application.conf
memcached=enabled
memcached.host=MEMCACHE_SERVERS
memcached.user=MEMCACHE_USERNAME
memcached.password=MEMCACHE_PASSWORD
Application.scala
package controllers
 
import play.api.data.Form
import play.api.data.Forms.{single, nonEmptyText}
import play.api.mvc.{Action, Controller}
import anorm.NotAssigned
import play.api.cache.Cache
import play.api.cache.Cached
import play.api.Play.current
 
 
object Application extends Controller {

  def index = Cached("home_page") {
    Action {
      Ok(views.html.index())
    }
  }

}
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?