{"id":13411748,"url":"https://github.com/resque/redis-namespace","last_synced_at":"2025-04-09T02:13:30.444Z","repository":{"id":692252,"uuid":"336504","full_name":"resque/redis-namespace","owner":"resque","description":"This gem adds a Redis::Namespace class which can be used to namespace Redis keys.","archived":false,"fork":false,"pushed_at":"2024-08-02T02:01:11.000Z","size":308,"stargazers_count":695,"open_issues_count":27,"forks_count":193,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-03-20T20:26:58.763Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://redis.io","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/resque.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2009-10-13T21:48:43.000Z","updated_at":"2025-03-05T16:59:08.000Z","dependencies_parsed_at":"2024-10-22T11:44:49.941Z","dependency_job_id":null,"html_url":"https://github.com/resque/redis-namespace","commit_stats":{"total_commits":261,"total_committers":105,"mean_commits":"2.4857142857142858","dds":0.8237547892720307,"last_synced_commit":"f9259a65e79bfa032e06d685b0c5730d3eb4870f"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resque%2Fredis-namespace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resque%2Fredis-namespace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resque%2Fredis-namespace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/resque%2Fredis-namespace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/resque","download_url":"https://codeload.github.com/resque/redis-namespace/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247229471,"owners_count":20905056,"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":[],"created_at":"2024-07-30T20:01:16.484Z","updated_at":"2025-04-09T02:13:30.408Z","avatar_url":"https://github.com/resque.png","language":"Ruby","readme":"redis-namespace\n===============\n\nRedis::Namespace provides an interface to a namespaced subset of your [redis][] keyspace (e.g., keys with a common beginning), and requires the [redis-rb][] gem.\n\n```ruby\nrequire 'redis-namespace'\n# =\u003e true\n\nredis_connection = Redis.new\n# =\u003e #\u003cRedis client v3.1.0 for redis://127.0.0.1:6379/0\u003e\nnamespaced_redis = Redis::Namespace.new(:ns, redis: redis_connection)\n# =\u003e #\u003cRedis::Namespace v1.5.0 with client v3.1.0 for redis://127.0.0.1:6379/0/ns\u003e\n\nnamespaced_redis.set('foo', 'bar') # redis_connection.set('ns:foo', 'bar')\n# =\u003e \"OK\"\n\n# Redis::Namespace automatically prepended our namespace to the key\n# before sending it to our redis client.\n\nnamespaced_redis.get('foo')\n# =\u003e \"bar\"\nredis_connection.get('foo')\n# =\u003e nil\nredis_connection.get('ns:foo')\n# =\u003e \"bar\"\n\nnamespaced_redis.del('foo')\n# =\u003e 1\nnamespaced_redis.get('foo')\n# =\u003e nil\nredis_connection.get('ns:foo')\n# =\u003e nil\n```\n\nRedis::Namespace also supports `Proc` as a namespace and will take the result string as namespace at runtime.\n\n```ruby\nredis_connection = Redis.new\nnamespaced_redis = Redis::Namespace.new(Proc.new { Tenant.current_tenant }, redis: redis_connection)\n```\n\nInstallation\n============\n\nRedis::Namespace is packaged as the redis-namespace gem, and hosted on rubygems.org.\n\nFrom the command line:\n\n    $ gem install redis-namespace\n\nOr in your Gemfile:\n\n```ruby\ngem 'redis-namespace'\n```\n\nCaveats\n=======\n\n`Redis::Namespace` provides a namespaced interface to `Redis` by keeping an internal registry of the method signatures in `Redis` provided by the [redis-rb][] gem; we keep track of which arguments need the namespace added, and which return values need the namespace removed.\n\nBlind Passthrough\n-----------------\nIf your version of this gem doesn't know about a particular command, it can't namespace it. Historically, this has meant that Redis::Namespace blindly passes unknown commands on to the underlying redis connection without modification which can lead to surprising effects.\n\nAs of v1.5.0, blind passthrough has been deprecated, and the functionality will be removed entirely in 2.0.\n\nIf you come across a command that is not yet supported, please open an issue on the [issue tracker][] or submit a pull-request.\n\nAdministrative Commands\n-----------------------\nThe effects of some redis commands cannot be limited to a particular namespace (e.g., `FLUSHALL`, which literally truncates all databases in your redis server, regardless of keyspace). Historically, this has meant that Redis::Namespace intentionally passes administrative commands on to the underlying redis connection without modification, which can lead to surprising effects.\n\nAs of v1.6.0, the direct use of administrative commands has been deprecated, and the functionality will be removed entirely in 2.0; while such commands are often useful for testing or administration, their meaning is inherently hidden when placed behind an interface that implies it will namespace everything.\n\nThe prefered way to send an administrative command is on the redis connection itself, which is publicly exposed as `Redis::Namespace#redis`:\n\n```ruby\nnamespaced.redis.flushall()\n# =\u003e \"OK\"\n```\n\n2.x Planned Breaking Changes\n============================\n\nAs mentioned above, 2.0 will remove blind passthrough and the administrative command passthrough.\nBy default in 1.5+, deprecation warnings are present and enabled;\nthey can be silenced by initializing `Redis::Namespace` with `warning: false` or by setting the `REDIS_NAMESPACE_QUIET` environment variable.\n\nEarly opt-in\n------------\n\nTo enable testing against the 2.x interface before its release, in addition to deprecation warnings, early opt-in to these changes can be enabled by initializing `Redis::Namespace` with `deprecations: true` or by setting the `REDIS_NAMESPACE_DEPRECATIONS` environment variable.\nThis should only be done once all warnings have been addressed.\n\nAuthors\n=======\n\nWhile there are many authors who have contributed to this project, the following have done so on an ongoing basis with at least 5 commits:\n\n - Chris Wanstrath (@defunkt)\n - Ryan Biesemeyer (@yaauie)\n - Steve Klabnik (@steveklabnik)\n - Terence Lee (@hone)\n - Eoin Coffey (@ecoffey)\n\n[redis]: http://redis.io\n[redis-rb]: https://github.com/redis/redis-rb\n[issue tracker]: https://github.com/resque/redis-namespace/issues\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fresque%2Fredis-namespace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fresque%2Fredis-namespace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fresque%2Fredis-namespace/lists"}