Add Redis gem and Create RedisClient (#4582)

* Add redis gem and client

* use keyword arguments in redis initializer

* check for REDISCLOUD_URL and fallback on REDIS_URL when connecting to redis

* dont parse Redis url in initializer
This commit is contained in:
Molly Struve 2019-10-30 09:32:59 -05:00 committed by Ben Halpern
parent 198efec024
commit 69e35dc1b3
8 changed files with 47 additions and 0 deletions

View file

@ -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 ##############
################################################

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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. <https://github.com/thepracticaldev/dev.to/fork>

View file

@ -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. <https://github.com/thepracticaldev/dev.to/fork>

View file

@ -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. <https://github.com/thepracticaldev/dev.to/fork>

View file

@ -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