{"id":13521185,"url":"https://github.com/sds/mock_redis","last_synced_at":"2025-05-13T20:21:03.015Z","repository":{"id":1573367,"uuid":"2014670","full_name":"sds/mock_redis","owner":"sds","description":"Mock Redis gem for Ruby","archived":false,"fork":false,"pushed_at":"2024-12-04T23:15:48.000Z","size":1055,"stargazers_count":496,"open_issues_count":4,"forks_count":156,"subscribers_count":44,"default_branch":"main","last_synced_at":"2025-04-13T02:00:07.294Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sds.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2011-07-07T21:10:29.000Z","updated_at":"2025-04-10T13:21:35.000Z","dependencies_parsed_at":"2023-11-16T19:48:15.178Z","dependency_job_id":"7519d703-6042-47d0-b151-cdc746023e91","html_url":"https://github.com/sds/mock_redis","commit_stats":{"total_commits":642,"total_committers":118,"mean_commits":5.440677966101695,"dds":0.7180685358255452,"last_synced_commit":"e01aae0be5165682a161c930da6081f959e95b3e"},"previous_names":[],"tags_count":79,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sds%2Fmock_redis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sds%2Fmock_redis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sds%2Fmock_redis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sds%2Fmock_redis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sds","download_url":"https://codeload.github.com/sds/mock_redis/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654045,"owners_count":21140235,"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-08-01T06:00:30.230Z","updated_at":"2025-04-13T02:00:14.830Z","avatar_url":"https://github.com/sds.png","language":"Ruby","funding_links":[],"categories":["Ruby","Mocks"],"sub_categories":[],"readme":"# MockRedis\n\n[![Gem Version](https://badge.fury.io/rb/mock_redis.svg)](http://badge.fury.io/rb/mock_redis)\n![Build Status](https://github.com/sds/mock_redis/actions/workflows/tests.yml/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/sds/mock_redis/badge.svg)](https://coveralls.io/r/sds/mock_redis)\n\nMockRedis provides the same interface as `redis-rb`, but it stores its\ndata in memory instead of talking to a Redis server. It is intended\nfor use in tests.\n\n## Requirements\n\nRuby 3.x\nredis-rb 5.x\n\nThe current implementation is **tested against Redis 6.2 and 7.0**. Older versions may work, but can also return different results or not support some commands.\n\n## Getting Started\n\nInstall the gem:\n\n```bash\ngem install mock_redis\n```\n\nIt's as easy as `require 'mock_redis'; mr = MockRedis.new`. Then you can\ncall the same methods on it as you can call on a real `Redis` object.\n\nFor example:\n\n```ruby\nrequire 'mock_redis'\nmr = MockRedis.new\nmr.set('some key', 'some value') # =\u003e \"OK\"\nmr.get('some key') # =\u003e \"some value\"\n```\n## Supported Features\n\nmock_redis supports most of the methods that redis-rb does. Examples\nof supported methods:\n\n* String methods: `get`, `set`, `append`, `incr`, etc.\n* List methods: `lpush`, `lpop`, `lrange`, `rpoplpush`, etc.\n* Set methods: `sadd`, `sinter`, `sismember`, `srandmember`, etc.\n* Hash methods: `hset`, `hget`, `hgetall`, `hmget`, `hincrby`, `hincrbyfloat` etc.\n* Sorted set methods: `zadd`, `zrank`, `zunionstore`, etc.\n* Expirations: `expire`, `pexpire`, `ttl`, `pttl`, etc.\n* Transactions: `multi`, `exec`, `discard`\n* Futures\n\n## Mostly-Supported Commands\n\nA MockRedis object can't do everything that a real Redis client can\nsince it's an in-memory object confined to a single process. MockRedis\nmakes every attempt to be Redis-compatible, but there are some\nnecessary exceptions.\n\n* Blocking list commands (`#blmove`, `#blpop`, `#brpop`, and `#brpoplpush`)\n  work as expected if there is data for them to retrieve. If you use one of\n  these commands with a nonzero timeout and there is no data for it to\n  retrieve, then the command returns immediately. However, if you ask\n  one of these commands for data with a 0 timeout (means \"wait\n  forever\") and there is no data available, then a\n  `MockRedis::WouldBlock` exception is raised. It's not what a real\n  Redis client would do, but it beats hanging your test run forever.\n\n* `#info` just returns canned values; they don't update over time.\n\n* `#sort` supports ascending and descending sort. `ALPHA` sort is not yet\n  supported.\n\n## Unsupported Commands\n\nSome stuff, we just can't do with a single Ruby object in a single\nRuby process.\n\n* Debugging commands (`#debug('object', key)` and\n  `#debug('segfault')`) aren't available.\n\n* `#object` isn't available since we don't have any Redis internals to\n  poke at.\n\n* `#monitor` isn't available; there's no place for requests to come\n  from, so there's nothing to receive.\n\n* Pubsub commands (`#psubscribe`, `#publish`, `#punsubscribe`) aren't\n  available.\n\n* `#slowlog` isn't available.\n\n* Scripting commands (`#script`, `#eval`, `#evalsha`) are just stubs\u0026mdash;they won't execute anything\n\n## Remaining Work\n\nThere are some things we want to have in here, but that we just\nhaven't gotten to doing yet. If you're interested in helping out,\nplease submit a pull request with your (tested!) implementation.\n\n* `#config(:get|:set|:resetstat)` isn't done. They can just return\n  canned values.\n\n## Running tests\n\nWe recommend running Redis within a Docker container to make development as simple as possible, but as long as you have a Redis instance listening on `localhost:6379` you should be good to go.\n\n1. Start Redis.\n   ```bash\n   docker run --rm -p 6379:6379 redis:6.2-alpine\n   ```\n2. Install dependencies.\n   ```bash\n   bundle install\n   ```\n3. Run tests.\n   ```bash\n   bundle exec rspec\n   ```\n\nThese tests were written with Redis running on `localhost` without any\npasswords required. If you're using a different version of Redis, you\nmay see failures due to error message text being different and other\nbreaking changes over time.\n\n## Changelog\n\nIf you're interested in seeing the changes and bug fixes between each version of `mock_redis`, read the [MockRedis Changelog](CHANGELOG.md).\n\n## License\n\nThis project is released under the [MIT license](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsds%2Fmock_redis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsds%2Fmock_redis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsds%2Fmock_redis/lists"}