{"id":15562142,"url":"https://github.com/mrkamel/redlocker","last_synced_at":"2025-04-23T23:04:57.044Z","repository":{"id":45978446,"uuid":"422270503","full_name":"mrkamel/redlocker","owner":"mrkamel","description":"Acquire and keep distributed locks using redis","archived":false,"fork":false,"pushed_at":"2023-02-03T15:56:10.000Z","size":30,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-23T23:04:56.490Z","etag":null,"topics":[],"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/mrkamel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2021-10-28T16:07:40.000Z","updated_at":"2024-03-21T01:05:17.000Z","dependencies_parsed_at":"2023-02-18T08:35:15.243Z","dependency_job_id":null,"html_url":"https://github.com/mrkamel/redlocker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrkamel%2Fredlocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrkamel%2Fredlocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrkamel%2Fredlocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrkamel%2Fredlocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrkamel","download_url":"https://codeload.github.com/mrkamel/redlocker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250528732,"owners_count":21445516,"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-10-02T16:11:57.240Z","updated_at":"2025-04-23T23:04:56.995Z","avatar_url":"https://github.com/mrkamel.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Redlocker\n\n[![Build](https://github.com/mrkamel/redlocker/workflows/test/badge.svg)](https://github.com/mrkamel/redlocker/actions?query=workflow%3Atest+branch%3Amaster)\n[![Gem Version](https://badge.fury.io/rb/redlocker.svg)](http://badge.fury.io/rb/redlocker)\n\n**Acquire and keep distributed locks alive using redis**\n\nThere are already quite some ruby libraries available which use redis for the\npurpose of distributed locking, but they require you to specify the time\ntime-to-live of your locks. Contrary, Redlocker allows you to easily acquire\nand keep distributed locks alive using redis. An acquired lock gets\nautomatically renewed every second from a thread, i.e. its 5 second expiry\nvalue gets renewed in redis every second, and it gets released as soon as the\ngiven block finishes.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'redlocker'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install redlocker\n\n## Usage\n\nUsing Redlocker could not be easier:\n\n```ruby\nRedlockerClient = Redlocker::Client.new(redis: Redis.new)\n\nRedlockerClient.with_lock('some_lock', timeout: 5) do\n  # lock acquired\nend\n```\n\nIf the lock can not be acquired within the specified `timeout`, a\n`Redlocker::TimeoutError` is raised.\n\nWhen the block finishes or raises, the acquired lock gets freed.\n \nYou can optionally pass a `delay` when acquiring a lock, which specifies the\ntime to wait between subsequent calls which check in redis whether or not the\nlock is free. Default is 0.25 seconds:\n\n```ruby\nRedlockerClient.with_lock(\"some lock\", timeout: 5, delay: 1) do\n  # lock acquired\nend\n```\n\nIf you are using a shared redis, you can pass a namespace, which will be used for\nprefixing redis keys in addition to the default `redlocker:` namespace.\n\n```ruby\nRedlockerClient = Redlocker::Client.new(redis: Redis.new, namespace: \"my-namespace\")\n```\n\nThat's it.\n\n## Reference docs\n\nPlease find the reference docs at\n[http://www.rubydoc.info/github/mrkamel/redlocker](http://www.rubydoc.info/github/mrkamel/redlocker)\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run\n`bundle exec rspec` to run the tests. You can also run `bin/console` for an\ninteractive prompt that will allow you to experiment.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at\nhttps://github.com/mrkamel/redlocker.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT\nLicense](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrkamel%2Fredlocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrkamel%2Fredlocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrkamel%2Fredlocker/lists"}