Skip to content

Instantly share code, notes, and snippets.

@taisyo7333
Last active October 28, 2016 03:51
Show Gist options
  • Save taisyo7333/21b8931b0215d7c8939612cd02c53ed3 to your computer and use it in GitHub Desktop.
Save taisyo7333/21b8931b0215d7c8939612cd02c53ed3 to your computer and use it in GitHub Desktop.
Ruby (rails) + Redis

Initializers

# config/initializers/redis.rb
Redis.current = Redis.new(:url => ENV['REDIS_URL'])

docker-compose.yml

  web:
    build:
      context: .
    environment:
      REDIS_URL: redis://redis:6379
      .
      .
      .
    depends_on:
      - redis
  redis:
    image: redis:3.2.4
    ports:
      - "6379:6379"
      .
      .
      .

Usage

$ docker-compose run web rails console 

Redis.current.set "foo", "bar"
=> "OK"

Redis.current.get "foo"
=> "bar"

References URL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment