{"id":16746728,"url":"https://github.com/samuelgiles/lazy_resque","last_synced_at":"2026-04-20T03:31:48.076Z","repository":{"id":56880854,"uuid":"137392629","full_name":"samuelgiles/lazy_resque","owner":"samuelgiles","description":"Move Resque enqueues out of the Rails request cycle to help decrease time to first byte.","archived":false,"fork":false,"pushed_at":"2018-06-14T19:37:38.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-07T04:38:17.635Z","etag":null,"topics":["rails","resque","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samuelgiles.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-14T18:09:26.000Z","updated_at":"2018-06-14T19:37:39.000Z","dependencies_parsed_at":"2022-08-20T23:40:07.159Z","dependency_job_id":null,"html_url":"https://github.com/samuelgiles/lazy_resque","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/samuelgiles/lazy_resque","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelgiles%2Flazy_resque","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelgiles%2Flazy_resque/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelgiles%2Flazy_resque/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelgiles%2Flazy_resque/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samuelgiles","download_url":"https://codeload.github.com/samuelgiles/lazy_resque/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelgiles%2Flazy_resque/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000702,"owners_count":26082805,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","resque","ruby"],"created_at":"2024-10-13T02:08:14.231Z","updated_at":"2025-10-08T19:12:06.853Z","avatar_url":"https://github.com/samuelgiles.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"![lazyresque](https://user-images.githubusercontent.com/2643026/41417090-4bbacb40-6fe4-11e8-809e-3951e3dcd3a5.jpg)\n\n# Lazy Resque\n\nMove Resque enqueues out of the Rails request cycle to help decrease time to first byte.\n\n## Install\n\nFrom gem:\n```\ngem 'lazy_resque'\n```\n\nFrom source:\n```\ngem 'lazy_resque', git: 'git@github.com:samuelgiles/lazy_resque.git'\n```\n\n## Use\n\nTrigger the actual enqueue of the jobs after the request in an `after_action` block, this can be done\nby including `LazyResque::ControllerEnqueue` which will automatically add the `after_action` for you.\n\n```ruby\nclass ApplicationController \u003c ActionController::Base\n  include LazyResque::ControllerEnqueue\n\n  def index\n    Resque.lazy_enqueue(MyResqueJob, 1234, 'some_job_data')\n  end\nend\n```\n\n## Why?\n\nThough moving a long running task to a Resque job is beneficial the actual enqueuing process isn't free:\n\n- Any `before_enqueue` hooks are run\n- A new job instance is initialized and validated\n- Arguments are dumped/encoded into JSON\n- Redis `rpush` takes places requiring communication with the Redis server\n\nThis is fine for 1-2 enqueues in a request cycle but can add up to a measurable amount of time if your enqueuing several jobs.\n\nYou don't lose anything by moving the actual enqueuing outside  the request cycle and it saves precious milliseconds.\n\n## How?\n\n![yodawg](https://user-images.githubusercontent.com/2643026/41434108-9f6acd2a-7012-11e8-9ee6-9925090802db.png)\n\nInternally when you call `Resque.lazy_enqueue` the job class and arguments are stored in an array on a per request thread variable, then at the end of the request via the `after_action` callback the queue is looped through and the jobs are actually sent to Resque.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelgiles%2Flazy_resque","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamuelgiles%2Flazy_resque","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelgiles%2Flazy_resque/lists"}