LoginSignup
0
5

More than 5 years have passed since last update.

HerokuでRedisを使う

Posted at

heroku-redisというアドオンが無料で使える。

インストール({app_name}はHeroku上のアプリ名)

$ heroku plugins:install heroku-redis --app {app_name}

REDIS_URLは自動的に設定される。

$ heroku config --app {app_name} | grep REDIS
REDIS_URL:                    redis://h:pe1xxxxxxxxxxxxx@ec2-54-225-230-xx.compute-1.amazonaws.com:22309

Redisインスタンスの情報を確認

$ heroku redis:info -app {app_name}
=== redis-opaque-57036 (REDIS_URL)
Plan:               Hobby Dev
Status:             available
Created:            2017-01-09 08:37 UTC
Version:            3.2.4
Timeout:            300
Maxmemory:          noeviction
Maintenance:        not required
Maintenance window: Fridays 19:00 to 23:00 UTC
Persistence:        None

上の例のredis-opaque-57036というのが下に出てくる{redis_name}になる。こちらを参考にして、タイムアウトとメモリ不足時の処理を設定する。

$ heroku redis:timeout {redis_name} --seconds 60 --app {app_name}
$ heroku redis:maxmemory {redis_name} --policy volatile-lru --app {app_name}

Redis CLIで接続

$ heroku redis:cli --app {app_name} --confirm {app_name}
0
5
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
0
5