<commit_before># Thredded + Redis + Resque

Out of the gate thredded does require anything other than a recent version of
ruby, and postgres and it works fine as is. There is a need over time to speed
things up with something like a background job processing queue, or a nosql
store like redis to help speed things up.

This gem helps do that. Using [resque] and [resque_mailer] it automatically
updates all mailers to push into resque instead of sending immediately. For now
that's all it does, but in time it will do more.

[resque]: https://github.com/defunkt/resque
[resque_mailer]: https://github.com/zapnap/resque_mailer

## Installation

* Dependencies:
  1. Redis must be installed. If you're on a mac: `brew install redis` and follow the directions.
  2. Use [foreman] ([railscast episode]) locally, and have a Procfile set up (there is a default Procfile in the thredded repo). This isn't a hard and fast requirement but it will certainly make things easier.
* Add this gem into your thredded app **Gemfile** - `gem 'thredded_resque'`
* Install with - `bundle install`
* Run the generator - `rails g thredded_resque:install`. This will append a worker to your Procfile.
* Start your local server and worker with foreman (`foreman start`) or start both of them
  individually: 

```
bundle exec rails server
bundle exec rake environment resque:work QUEUE='*'
```

[foreman]: https://github.com/ddollar/foreman
[railscast episode]: http://railscasts.com/episodes/281-foreman

## Using with heroku<commit_msg>Update README w/Heroku-specific instructions<commit_after># Thredded + Redis + Resque

Out of the gate thredded does require anything other than a recent version of
ruby, and postgres and it works fine as is. There is a need over time to speed
things up with something like a background job processing queue, or a nosql
store like redis to help speed things up.

This gem helps do that. Using [resque] and [resque_mailer] it automatically
updates all mailers to push into resque instead of sending immediately. For now
that's all it does, but in time it will do more.

[resque]: https://github.com/defunkt/resque
[resque_mailer]: https://github.com/zapnap/resque_mailer

## Installation

* Dependencies:
  1. Redis must be installed. If you're on a mac: `brew install redis` and follow the directions.
  2. Use [foreman] ([railscast episode]) locally, and have a Procfile set up (there is a default Procfile in the thredded repo). This isn't a hard and fast requirement but it will certainly make things easier.
* Add this gem into your thredded app **Gemfile** - `gem 'thredded_resque'`
* Install with - `bundle install`
* Run the generator - `rails g thredded_resque:install`. This will append a worker to your Procfile.
* Start your local server and worker with foreman (`foreman start`) or start both of them
  individually: 

```
bundle exec rails server
bundle exec rake environment resque:work QUEUE='*'
```

[foreman]: https://github.com/ddollar/foreman
[railscast episode]: http://railscasts.com/episodes/281-foreman

## Using with heroku

* Install a redis addon like redistogo

```
heroku addons:add redistogo:nano
```

* Add a worker process. Remember - this costs $!

```
heroku ps:scale worker=1
```

* Ensure the app is set up to connect to redistogo.

`config/initializers/redis.rb`

```
uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS_WORKER = Redis.new(host: uri.host, port: uri.port, password: uri.password)
```


`config/initializers/resque.rb`

```
Resque.redis = REDIS_WORKER
```
{'fraction_non_alphanumeric': 0.08824366638200967, 'fraction_numerical': 0.0031312268716196983, 'mean_word_length': 4.482059282371295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3246444', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1052, 'n_words': 466}