This article shows about cacing data & session management with Ruby on Rails.
π Installation
Add the following βredis-railsβ to your Gemfile
:
# Redis stores |
Letβs execute bundle install
on your terminal.
πΌ Usage
Add the following to your environment variable or .env
:
REDIS_URL="redis://localhost:6379/0/cache" |
Configure to use Redis for cache store is as follows:
# config/application.rb |
If you want to use Redis as a backend for sessions, you should also set:
# config/initializers/session_store.rb |
If you want to skip to cache on TEST environment, please set NullStore:
# config/environments/test.rb: |
Happy Hacking!
π½ Special Thanks
- caching - is Rails.cache purged between tests? - Stack Overflow
- http://morizyun.github.io/blog/redis-rails-session-ruby/
π₯ Recommended VPS Service
VULTR provides high performance cloud compute environment for you.
Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour).
In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!