A summary of data about the Ruby ecosystem.

https://github.com/redis-store/redis-rails

Redis stores for Ruby on Rails
https://github.com/redis-store/redis-rails

Keywords

rails redis redis-store ruby

Keywords from Contributors

activejob activerecord mvc rubygems ruby-gem background-jobs rspec rubocop crash-reporting sidekiq

Last synced: about 23 hours ago
JSON representation

Repository metadata

Redis stores for Ruby on Rails

README.md

Redis stores for Ruby on Rails

redis-rails provides a full set of stores (Cache, Session, HTTP Cache) for Ruby on Rails. See the main redis-store readme for general guidelines.

A quick note about Rails 5.2

Rails 5.2.0 includes a Redis cache store out of the
box
, so you don't really
need this gem anymore if you just need to store the fragment cache in
Redis. Maintenance on the
redis-activesupport
gem will continue for security and compatibility issues, but we are no
longer accepting new features. We are still actively maintaining all
other gems in the redis-store family, such as
redis-actionpack
for session management, and
redis-rack-cache
for HTTP cache storage.

Looking for issues? You probably want to create an issue for one of
our other gems. Check this org to find the right one.

Installation

Add the following to your Gemfile:

gem 'redis-rails'

Usage

redis-rails packages storage drivers for Redis which implement the
ActiveSupport fragment caching and ActionDispatch / Rack session
storage APIs. The following section(s) explain how to configure each
store:

Rails Fragment Cache

Configure the fragment cache store in config/environments/production.rb like so:

config.cache_store = :redis_store, "redis://localhost:6379/0/cache", { expires_in: 90.minutes }

The ActiveSupport::Cache::Store implementation assumes that your
backend store (Redis, Memcached, etc) will be available at boot time. If
you cannot guarantee this, you can use the raise_errors: false option
to rescue connection errors.

You can also provide a hash instead of a URL:

config.cache_store = :redis_store, {
  host: "localhost",
  port: 6379,
  db: 0,
  password: "mysecret",
  namespace: "cache"
}, {
  expires_in: 90.minutes
}

Session Storage

If you need session storage, consider directly using
redis-actionpack
instead.

You can also store your session data in Redis, keeping user-specific
data isolated, shared, and highly available. Built upon redis-rack,
we present the session data to the user as a signed/encrypted cookie,
but we persist the data in Redis.

Add the following to your config/initializers/session_store.rb to
use Redis as the session store.

MyApplication::Application.config.session_store :redis_store,
  servers: ["redis://localhost:6379/0/session"],
  expire_after: 90.minutes,
  key: "_#{Rails.application.class.parent_name.downcase}_session",
  threadsafe: true,
  secure: true

A brief run-down of these options...

  • servers is an Array of Redis servers that we will attempt to find
    data from. This uses the same syntax as :redis_store
  • expire_after is the default TTL of session keys. This is also set
    as the expiry time of any cookies generated by the session store.
  • key is the name of the cookie on the client side
  • threadsafe is for applications that run on multiple instances. Set
    this to false if you want to disable the global mutex lock on
    session data. It's true by default, meaning the mutex will be
    enabled.
  • signed uses signed/encrypted cookies to store the local session on
    a client machine, preventing a malicious user from tampering with its
    contents.
  • secure ensures HTTP cookies are transferred from server to client
    on a secure (HTTPS) connection
  • httponly ensures that all cookies have the HttpOnly flag set to true

HTTP Caching

We also provide an adapter for
Rack::Cache that lets you store HTTP
caching data in Redis. To take advantage of this, add the following to
Gemfile:

group :production do
  gem 'redis-rack-cache'
end

Then, add the following to config/environments/production.rb:

# config/environments/production.rb
config.action_dispatch.rack_cache = {
  metastore: "redis://localhost:6379/1/metastore",
  entitystore: "redis://localhost:6379/1/entitystore"
}

Usage with Redis Sentinel

You can also use Redis Sentinel to manage a cluster of Redis servers
for high-availability data access. To do so, configure the sentinel
servers like so:

sentinel_config = {
  url: "redis://mymaster/0",
  role: "master",
  sentinels: [{
    host: "127.0.0.1",
    port: 26379
  },{
    host: "127.0.0.1",
    port: 26380
  },{
    host: "127.0.0.1",
    port: 26381
  }]
}

You can then include this in your cache store configuration within
config/environments/production.rb:

config.cache_store = :redis_store, sentinel_config.merge(
  namespace: "cache",
  expires_in: 1.days
)
config.session_store :redis_store, {
  servers: [
    sentinel_config.merge(
      namespace: "sessions"
    )
  ],
  expire_after: 2.days
}

Usage with Redis Cluster

You can also specify only a subset of the nodes, and the client will discover the missing ones using the CLUSTER NODES command.

config.cache_store = :redis_store, { cluster: %w[redis://127.0.0.1:6379/0/] }

Running tests

gem install bundler
git clone git://github.com/redis-store/redis-rails.git
cd redis-rails
RAILS_VERSION=5.0.1 bundle install
RAILS_VERSION=5.0.1 bundle exec rake

If you are on Snow Leopard, run env ARCHFLAGS="-arch x86_64" bundle exec rake

Status

Gem Version
CI
Code Climate

Copyright

2009 - 2018 Luca Guidi - http://lucaguidi.com, released under the MIT license


Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 3 days ago

Total Commits: 93
Total Committers: 28
Avg Commits per committer: 3.321
Development Distribution Score (DDS): 0.774

Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0

Name Email Commits
Tom Scott t****t@w****m 21
Nicolas Rodriguez n****o@n****r 13
Tom Scott t****o 12
Ryan Bigg g****t@r****m 12
Schuyler Jager s****r@j****m 3
Jared Beck j****d@j****m 3
Luca Guidi me@l****m 3
Luca Guidi g****a@g****m 2
Garrett Thornburg f****2@g****m 2
Marcelo Boeira me@m****m 2
Popa Adrian Marius m****a@r****t 2
shiro16 n****4@g****m 2
Tim Rogers t****m@g****m 1
Agung Setiawan c****n@g****m 1
Dan Simpson d****n@g****m 1
Grey Baker g****l@g****m 1
Jake Goulding j****g@g****m 1
Laurent Arnoud l****t@s****t 1
Miles Matthias m****s@g****m 1
Molly Struve m****s@g****m 1
Olle Jonsson o****n@g****m 1
Rico Sta. Cruz r****z 1
Ryan Mark r****n@m****c 1
ars moriendi h****o 1
hilotter h****3@g****m 1
masatooba d****v@m****m 1
mishina t****8@g****m 1
tnantoka t****a@b****m 1

Committer domains:


Issue and Pull Request metadata

Last synced: 17 days ago

Total issues: 0
Total pull requests: 40
Average time to close issues: N/A
Average time to close pull requests: 3 months
Total issue authors: 0
Total pull request authors: 32
Average comments per issue: 0
Average comments per pull request: 1.63
Merged pull request: 30
Bot issues: 0
Bot pull requests: 0

Past year issues: 0
Past year pull requests: 4
Past year average time to close issues: N/A
Past year average time to close pull requests: 3 months
Past year issue authors: 0
Past year pull request authors: 4
Past year average comments per issue: 0
Past year average comments per pull request: 1.75
Past year merged pull request: 1
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/redis-store/redis-rails

Top Issue Authors

Top Pull Request Authors

  • tubbo (6)
  • jaredbeck (3)
  • n-rodriguez (3)
  • BoomchainLabs (2)
  • ivanFigurenko (2)
  • gogainda (2)
  • f440 (2)
  • schuylr (1)
  • greysteil (1)
  • horacio (1)
  • film42 (1)
  • tnantoka (1)
  • masatooba (1)
  • DougPuchalski (1)
  • rstacruz (1)

Top Issue Labels

Top Pull Request Labels


Package metadata

gem.coop: redis-rails

Redis for Ruby on Rails

  • Homepage: http://redis-store.org/redis-rails
  • Documentation: http://www.rubydoc.info/gems/redis-rails/
  • Licenses: MIT
  • Latest release: 5.0.2 (published almost 9 years ago)
  • Last Synced: 2026-03-01T17:03:21.967Z (2 days ago)
  • Versions: 19
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 82,868,385 Total
  • Docker Downloads: 597,329
  • Rankings:
    • Dependent repos count: 0.0%
    • Dependent packages count: 0.0%
    • Downloads: 0.335%
    • Average: 0.451%
    • Docker downloads count: 1.471%
  • Maintainers (5)
rubygems.org: redis-rails

Redis for Ruby on Rails

  • Homepage: http://redis-store.org/redis-rails
  • Documentation: http://www.rubydoc.info/gems/redis-rails/
  • Licenses: MIT
  • Latest release: 5.0.2 (published almost 9 years ago)
  • Last Synced: 2026-03-02T07:03:17.451Z (1 day ago)
  • Versions: 19
  • Dependent Packages: 20
  • Dependent Repositories: 4,963
  • Downloads: 82,875,055 Total
  • Docker Downloads: 597,329
  • Rankings:
    • Downloads: 0.26%
    • Dependent repos count: 0.45%
    • Dependent packages count: 1.051%
    • Average: 1.311%
    • Docker downloads count: 1.771%
    • Stargazers count: 1.925%
    • Forks count: 2.412%
  • Maintainers (5)
proxy.golang.org: github.com/redis-store/redis-rails


Dependencies

redis-rails.gemspec rubygems
  • appraisal >= 0 development
  • bundler ~> 2 development
  • minitest >= 4.2, < 6 development
  • mocha ~> 0.14.0 development
  • rake >= 12.3.3 development
  • redis-store-testing >= 0 development
  • redis-actionpack >= 3.0, < 8
  • redis-activesupport >= 3.0, < 8
.github/workflows/ruby.yml actions
  • actions/checkout v2 composite
  • ruby/setup-ruby v1 composite
Gemfile rubygems

Score: 29.150878480797825