{"id":16681437,"url":"https://github.com/printercu/pooled_redis","last_synced_at":"2025-03-21T18:32:43.053Z","repository":{"id":56888493,"uuid":"29583930","full_name":"printercu/pooled_redis","owner":"printercu","description":"Simple way to access redis connections without global variables.","archived":false,"fork":false,"pushed_at":"2015-03-30T08:11:31.000Z","size":228,"stargazers_count":18,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-24T18:11:26.000Z","etag":null,"topics":["pool","rails","redis","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"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/printercu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-21T10:12:13.000Z","updated_at":"2021-05-09T14:02:12.000Z","dependencies_parsed_at":"2022-08-20T16:00:14.191Z","dependency_job_id":null,"html_url":"https://github.com/printercu/pooled_redis","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/printercu%2Fpooled_redis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/printercu%2Fpooled_redis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/printercu%2Fpooled_redis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/printercu%2Fpooled_redis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/printercu","download_url":"https://codeload.github.com/printercu/pooled_redis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221817591,"owners_count":16885572,"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":["pool","rails","redis","ruby"],"created_at":"2024-10-12T14:04:12.962Z","updated_at":"2024-10-28T10:36:00.241Z","avatar_url":"https://github.com/printercu.png","language":"Ruby","readme":"# PooledRedis\n\n[![Gem Version](https://badge.fury.io/rb/pooled_redis.svg)](http://badge.fury.io/rb/pooled_redis)\n[![Build Status](https://travis-ci.org/printercu/pooled_redis.svg)](https://travis-ci.org/printercu/pooled_redis)\n\nSimple way to access redis connections without global variables.\n\nProvides `Rails.redis_pool` \u0026 `Rails.redis` methods and configuration via `database.yml`.\nYou can add this methods to custom modules.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'pooled_redis'\n```\n\n## Usage\n\n- Add `redis` section to your `database.yml` with options supported by `Redis.new`\n\n```yml\ndevelopment:\n  redis:\n    db: 2\nproduction:\n  redis:\n    url: 'redis://mymaster'\n    sentinels:\n      - host: host\n      - host: other\n```\n\n- You can also provide `pool` \u0026 `timeout` values for ConnectionPool.\n- Use `debug: true` to set redis logger to `Rails.logger`.\n- Pass `namespace` if you want to use\n  [redis-namespace](https://github.com/resque/redis-namespace).\n- Use `Rails.redis_pool` \u0026 `Rails.redis` method.\n\nPooledRedis uses ConnectionPool for pooling connections.\n`.redis` returns proxy object that checkouts connection for every method call.\nSo you may want to avoid it for bulk operations.\n\n### Rails.cache configuration \u0026 Redis::Store support\nPooledRedis provides configuration of `Rails.cache` via `database.yml`.\nTo enable this add following to your `config/application.rb` (inside `Application` class):\n\n```ruby\nPooledRedis.setup_rails_cache(self)\n```\n\nAnd cache sections to `database.yml`:\n\n```yml\ndevelopment:\n  cache:\n    adapter: redis_store\n    db: 3\n    expires_in: 3600\n\nproduction:\n  cache:\n    adapter: redis_store\n    url: 'redis://mycachemaster'\n    sentinels:\n      - host: host\n      - host: other\n\n# You can also use other adapters:\ntest:\n  cache:\n    adapter: null_store\n```\n\nYou need to add `gem 'redis-activesupport'` to your Gemfile.\nIt supports only new version of `Redis::Store` with support of ConnectionPool\n(currently it's only available in master:\n`gem 'redis-activesupport', '~\u003e 4.0.0', github: 'redis-store/redis-activesupport', ref: 'd09ae04'`).\n\n### Custom modules or without rails\n\n- Extend or include `PooledRedis` module.\n- Override `redis_config` method to return valid configuration.\n- Use `redis_pool` \u0026 `redis` methods.\n\n```ruby\nclass Storage\n  extend PooledRedis\n\n  class \u003c\u003c self\n    def redis_config\n      read_your_yaml.symbolize_keys\n    end\n  end\n\n  # ...\n\n  def save\n    self.class.redis.set id, to_json\n  end\nend\n\nStorage.redis_pool.with { |r| r.get :some_key }\nStorage.redis.get :some_key\n```\n\n### Advanced usage\n\nYou can return hash containing `:block` from `redis_config`. This block\nwill be used as a block to instantiate connection in ConnectionPool.\n\n# Licence\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprintercu%2Fpooled_redis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprintercu%2Fpooled_redis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprintercu%2Fpooled_redis/lists"}