diff --git a/Envfile b/Envfile index 0113c3d67..64914d3ec 100644 --- a/Envfile +++ b/Envfile @@ -27,6 +27,9 @@ variable :RACK_TIMEOUT_SERVICE_TIMEOUT, :Integer, default: 100_000 # Production related config that can be ignored variable :DEPLOYMENT_SIGNATURE, :String, default: "Optional" +# For Redis storage +variable :REDIS_URL, :String, default: "redis://localhost:6379" + ################################################ ############## 3rd Party Services ############## ################################################ diff --git a/Gemfile b/Gemfile index 4daf12929..8e1b1acc0 100644 --- a/Gemfile +++ b/Gemfile @@ -73,6 +73,7 @@ gem "rails-assets-airbrake-js-client", "~> 1.6", source: "https://rails-assets.o gem "rails-observers", "~> 0.1" # Rails observer (removed from core in Rails 4.0) gem "recaptcha", "~> 5.2", require: "recaptcha/rails" # Helpers for the reCAPTCHA API gem "redcarpet", "~> 3.5" # A fast, safe and extensible Markdown to (X)HTML parser +gem "redis", "~> 4.1.3" # Redis ruby client gem "reverse_markdown", "~> 1.3" # Map simple html back into markdown gem "rolify", "~> 5.2" # Very simple Roles library gem "rouge", "~> 3.12" # A pure-ruby code highlighter diff --git a/Gemfile.lock b/Gemfile.lock index fdfb4081e..ea9016e72 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -613,6 +613,7 @@ GEM recaptcha (5.2.1) json redcarpet (3.5.0) + redis (4.1.3) regexp_parser (1.6.0) representable (3.0.4) declarative (< 0.1.0) @@ -949,6 +950,7 @@ DEPENDENCIES rails-observers (~> 0.1) recaptcha (~> 5.2) redcarpet (~> 3.5) + redis (~> 4.1.3) reverse_markdown (~> 1.3) rolify (~> 5.2) rouge (~> 3.12) diff --git a/config/initializers/redis.rb b/config/initializers/redis.rb new file mode 100644 index 000000000..99bcef418 --- /dev/null +++ b/config/initializers/redis.rb @@ -0,0 +1,5 @@ +# DEV uses the RedisCloud Heroku Add-On which comes with the predefined env variable REDISCLOUD_URL +redis_url = ENV["REDISCLOUD_URL"] +redis_url ||= ApplicationConfig["REDIS_URL"] + +RedisClient = Redis.new(url: redis_url) diff --git a/docs/installation/linux.md b/docs/installation/linux.md index 81d644e44..10054a209 100644 --- a/docs/installation/linux.md +++ b/docs/installation/linux.md @@ -31,6 +31,13 @@ DEV uses [ImageMagick](https://imagemagick.org/) to manipulate images on upload. Please refer to ImageMagick's [instructions](https://imagemagick.org/script/download.php) on how to install it. +### Redis + +DEV requires Redis version 4.0 or higher. + +We recommend following Digital Ocean's extensive [How To Install and Configure Redis on Ubuntu 16.04](https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-redis-on-ubuntu-16-04) +(available for other Linux distributions as well) to setup Redis. + ## Installing DEV 1. Fork DEV's repository, e.g. diff --git a/docs/installation/mac.md b/docs/installation/mac.md index 60262d076..229a4a810 100644 --- a/docs/installation/mac.md +++ b/docs/installation/mac.md @@ -27,6 +27,28 @@ DEV uses [ImageMagick](https://imagemagick.org/) to manipulate images on upload. You can install ImageMagick with `brew install imagemagick`. +### Redis + +DEV requires Redis version 4.0 or higher. + +We recommend using [Homebrew](https://brew.sh): + +```shell +brew install redis +``` + +you can follow the post installation instructions, we recommend using `brew services` to start Redis in the background: + +```shell +brew services start redis +``` + +You can test if it's up and running by issuing the following command: + +```shell +redis-cli ping +``` + ## Installing DEV 1. Fork DEV's repository, e.g. diff --git a/docs/installation/windows.md b/docs/installation/windows.md index fed11a285..38b325360 100644 --- a/docs/installation/windows.md +++ b/docs/installation/windows.md @@ -105,6 +105,12 @@ DEV uses [ImageMagick](https://imagemagick.org/) to manipulate images on upload. Please refer to ImageMagick's [instructions](https://imagemagick.org/script/download.php) on how to install it. +### Redis + +DEV requires Redis version 4.0 or higher. + +We recommend to follow [this guide](https://redislabs.com/blog/redis-on-windows-10/) to run Redis under WSL. + ## Installing DEV 1. Fork DEV's repository, eg. diff --git a/docs/technical-overview.md b/docs/technical-overview.md index 93cd852fe..20b338421 100644 --- a/docs/technical-overview.md +++ b/docs/technical-overview.md @@ -8,6 +8,7 @@ For the Dev.to tech stack we use: - [_Puma_](https://github.com/puma/puma) as the web server - [_PostgreSQL_](https://www.postgresql.org/) as the primary database +- [_Redis_](https://redis.io/) to store additional data and eventually replace memcache - [_Fastly_](https://www.fastly.com/) for [edge caching](https://dev.to/ben/making-devto-insanely-fast) - [_Cloudinary_](https://cloudinary.com/) for image manipulation/serving - [_Airbrake_](https://airbrake.io/) for error monitoring