{"id":13747365,"url":"https://github.com/redis-store/redis-rails","last_synced_at":"2025-05-13T16:07:10.414Z","repository":{"id":44946713,"uuid":"2346936","full_name":"redis-store/redis-rails","owner":"redis-store","description":"Redis stores for Ruby on Rails","archived":false,"fork":false,"pushed_at":"2024-11-26T04:07:05.000Z","size":103,"stargazers_count":977,"open_issues_count":2,"forks_count":126,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-18T13:28:01.295Z","etag":null,"topics":["rails","redis","redis-store","ruby"],"latest_commit_sha":null,"homepage":"http://redis-store.org/redis-rails","language":"Ruby","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/redis-store.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-09-08T07:17:49.000Z","updated_at":"2025-01-28T14:05:20.000Z","dependencies_parsed_at":"2024-11-05T18:36:08.512Z","dependency_job_id":"2f1a3dcc-759e-4b40-8a94-d0270a530438","html_url":"https://github.com/redis-store/redis-rails","commit_stats":{"total_commits":93,"total_committers":28,"mean_commits":"3.3214285714285716","dds":0.7741935483870968,"last_synced_commit":"b6a9c2bf4e31eabdde294e912200d05a2dcd4dda"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redis-store%2Fredis-rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redis-store%2Fredis-rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redis-store%2Fredis-rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redis-store%2Fredis-rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redis-store","download_url":"https://codeload.github.com/redis-store/redis-rails/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250365187,"owners_count":21418642,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rails","redis","redis-store","ruby"],"created_at":"2024-08-03T06:01:26.327Z","updated_at":"2025-04-23T20:45:48.892Z","avatar_url":"https://github.com/redis-store.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Redis stores for Ruby on Rails\n\n__`redis-rails`__ provides a full set of stores (*Cache*, *Session*, *HTTP Cache*) for __Ruby on Rails__. See the main [redis-store readme](https://github.com/redis-store/redis-store) for general guidelines.\n\n## A quick note about Rails 5.2\n\nRails 5.2.0 [includes a Redis cache store out of the\nbox](https://github.com/rails/rails/pull/31134), so you don't really\nneed this gem anymore if you just need to store the fragment cache in\nRedis. Maintenance on the\n[redis-activesupport](https://github.com/redis-store/redis-activesupport)\ngem will continue for security and compatibility issues, but we are no\nlonger accepting new features. We are still actively maintaining all\nother gems in the redis-store family, such as\n[redis-actionpack](https://github.com/redis-store/redis-actionpack)\nfor session management, and\n[redis-rack-cache](https://github.com/redis-store/redis-rack-cache)\nfor HTTP cache storage.\n\n**Looking for issues?** You probably want to create an issue for one of\nour other gems. Check this org to find the right one.\n\n## Installation\n\nAdd the following to your Gemfile:\n\n```ruby\ngem 'redis-rails'\n```\n\n## Usage\n\n`redis-rails` packages storage drivers for Redis which implement the\nActiveSupport fragment caching and ActionDispatch / Rack session\nstorage APIs. The following section(s) explain how to configure each\nstore:\n\n### Rails Fragment Cache\n\nConfigure the fragment cache store in **config/environments/production.rb** like so:\n\n```ruby\nconfig.cache_store = :redis_store, \"redis://localhost:6379/0/cache\", { expires_in: 90.minutes }\n```\n\nThe `ActiveSupport::Cache::Store` implementation assumes that your\nbackend store (Redis, Memcached, etc) will be available at boot time. If\nyou cannot guarantee this, you can use the `raise_errors: false` option\nto rescue connection errors.\n\nYou can also provide a hash instead of a URL:\n\n```ruby\nconfig.cache_store = :redis_store, {\n  host: \"localhost\",\n  port: 6379,\n  db: 0,\n  password: \"mysecret\",\n  namespace: \"cache\"\n}, {\n  expires_in: 90.minutes\n}\n```\n\n### Session Storage\n\nIf you need session storage, consider directly using\n[redis-actionpack](https://github.com/redis-store/redis-actionpack)\ninstead.\n\nYou can also store your session data in Redis, keeping user-specific\ndata isolated, shared, and highly available. Built upon [redis-rack](https://github.com/redis-store/redis-rack),\nwe present the session data to the user as a signed/encrypted cookie,\nbut we persist the data in Redis.\n\nAdd the following to your **config/initializers/session_store.rb** to\nuse Redis as the session store.\n\n```ruby\nMyApplication::Application.config.session_store :redis_store,\n  servers: [\"redis://localhost:6379/0/session\"],\n  expire_after: 90.minutes,\n  key: \"_#{Rails.application.class.parent_name.downcase}_session\",\n  threadsafe: true,\n  secure: true\n```\n\nA brief run-down of these options...\n\n- **servers** is an Array of Redis servers that we will attempt to find\n  data from. This uses the same syntax as `:redis_store`\n- **expire_after** is the default TTL of session keys. This is also set\n  as the expiry time of any cookies generated by the session store.\n- **key** is the name of the cookie on the client side\n- **threadsafe** is for applications that run on multiple instances. Set\n  this to `false` if you want to disable the global mutex lock on\n  session data. It's `true` by default, meaning the mutex will be\n  enabled.\n- **signed** uses signed/encrypted cookies to store the local session on\n  a client machine, preventing a malicious user from tampering with its\n  contents.\n- **secure** ensures HTTP cookies are transferred from server to client\n  on a secure (HTTPS) connection\n- **httponly** ensures that all cookies have the HttpOnly flag set to true\n\n### HTTP Caching\n\nWe also provide [an adapter](https://github.com/redis-store/redis-rack-cache) for\n[Rack::Cache](http://rtomayko.github.io/rack-cache/) that lets you store HTTP\ncaching data in Redis. To take advantage of this, add the following to\nGemfile:\n\n```ruby\ngroup :production do\n  gem 'redis-rack-cache'\nend\n```\n\nThen, add the following to **config/environments/production.rb**:\n\n```ruby\n# config/environments/production.rb\nconfig.action_dispatch.rack_cache = {\n  metastore: \"redis://localhost:6379/1/metastore\",\n  entitystore: \"redis://localhost:6379/1/entitystore\"\n}\n```\n\n### Usage with Redis Sentinel\n\nYou can also use [Redis Sentinel](https://redis.io/topics/sentinel) to manage a cluster of Redis servers\nfor high-availability data access. To do so, configure the sentinel\nservers like so:\n\n```ruby\nsentinel_config = {\n  url: \"redis://mymaster/0\",\n  role: \"master\",\n  sentinels: [{\n    host: \"127.0.0.1\",\n    port: 26379\n  },{\n    host: \"127.0.0.1\",\n    port: 26380\n  },{\n    host: \"127.0.0.1\",\n    port: 26381\n  }]\n}\n```\n\nYou can then include this in your cache store configuration within\n**config/environments/production.rb**:\n\n```ruby\nconfig.cache_store = :redis_store, sentinel_config.merge(\n  namespace: \"cache\",\n  expires_in: 1.days\n)\nconfig.session_store :redis_store, {\n  servers: [\n    sentinel_config.merge(\n      namespace: \"sessions\"\n    )\n  ],\n  expire_after: 2.days\n}\n```\n\n## Usage with Redis Cluster\n\nYou can also specify only a subset of the nodes, and the client will discover the missing ones using the [CLUSTER NODES](https://redis.io/commands/cluster-nodes) command.\n\n```ruby\nconfig.cache_store = :redis_store, { cluster: %w[redis://127.0.0.1:6379/0/] }\n```\n\n## Running tests\n\n```shell\ngem install bundler\ngit clone git://github.com/redis-store/redis-rails.git\ncd redis-rails\nRAILS_VERSION=5.0.1 bundle install\nRAILS_VERSION=5.0.1 bundle exec rake\n```\n\nIf you are on **Snow Leopard**, run `env ARCHFLAGS=\"-arch x86_64\" bundle exec rake`\n\n## Status\n\n[![Gem Version](https://badge.fury.io/rb/redis-rails.svg)](http://badge.fury.io/rb/redis-rails)\n[![CI](https://github.com/redis-store/redis-rails/actions/workflows/ruby.yml/badge.svg)](https://github.com/redis-store/redis-rails/actions/workflows/ruby.yml)\n[![Code Climate](https://codeclimate.com/github/redis-store/redis-rails.svg)](https://codeclimate.com/github/redis-store/redis-rails)\n\n## Copyright\n\n2009 - 2018 Luca Guidi - [http://lucaguidi.com](http://lucaguidi.com), released under the MIT license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredis-store%2Fredis-rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredis-store%2Fredis-rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredis-store%2Fredis-rails/lists"}