{"id":42848279,"url":"https://github.com/omnichat/middy-lock-redis","last_synced_at":"2026-01-30T12:00:20.566Z","repository":{"id":44549662,"uuid":"443092184","full_name":"OmniChat/middy-lock-redis","owner":"OmniChat","description":"middleware to prevent concurrent execution of a lambda for the same object. Controlled with redis. You need to use the \"middle\" library.","archived":false,"fork":false,"pushed_at":"2023-03-28T15:14:13.000Z","size":321,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-09-03T22:52:23.340Z","etag":null,"topics":["concurrent","lambda","redis","serverless","sqs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/OmniChat.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":"2021-12-30T14:04:37.000Z","updated_at":"2022-02-08T16:52:10.000Z","dependencies_parsed_at":"2024-12-21T19:30:51.579Z","dependency_job_id":"be15d371-9f3c-4698-ad5c-b3e878bf4c96","html_url":"https://github.com/OmniChat/middy-lock-redis","commit_stats":{"total_commits":33,"total_committers":2,"mean_commits":16.5,"dds":"0.12121212121212122","last_synced_commit":"ff8b41361491c2d69783a3cf10c024fe59387fb4"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/OmniChat/middy-lock-redis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmniChat%2Fmiddy-lock-redis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmniChat%2Fmiddy-lock-redis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmniChat%2Fmiddy-lock-redis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmniChat%2Fmiddy-lock-redis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OmniChat","download_url":"https://codeload.github.com/OmniChat/middy-lock-redis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmniChat%2Fmiddy-lock-redis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28912208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T11:55:24.701Z","status":"ssl_error","status_checked_at":"2026-01-30T11:54:13.194Z","response_time":66,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["concurrent","lambda","redis","serverless","sqs"],"created_at":"2026-01-30T12:00:17.227Z","updated_at":"2026-01-30T12:00:20.557Z","avatar_url":"https://github.com/OmniChat.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Middy Lock Redis\n\nCustom middleware created to lock redis on input and unlock on output lambda execution\n\nNote - designed for use in HTTP and SQS functions\n\n![Fluxo](https://raw.githubusercontent.com/OmniChat/middy-lock-redis/main/image/fluxo2.png)\n\n## Install\n\nTo install this middleware you can use NPM:\n\n```ssh\n$ npm install --save @omnichat/middy-lock-redis\n```\n\n## Usage Example\n\n```typescript\nimport middy from '@middy/core';\nimport { MiddlewareLock } from '@omnichat/middy-lock-redis';\nimport { Redis } from 'ioredis';\n\nconst redis = new Redis({\n    host: 'http://localhost/',\n    port: 6379,\n});\n\nexport const baseHandler = async (event) =\u003e {\n  return {\n    statusCode: 200,\n    headers: {},\n    body: event.body,\n  };\n};\n\nexports.handler = middy(baseHandler).use(\n  MiddlewareLock('prefix', 'key', client, ttl, options),\n);\n```\n\n## Information\n\nFor use in SQS when configured in lambda, ( event \u003e sqs \u003e batchSize ) it is necessary to add another property which is :\n\nfunctionResponseTypes: ReportBatchItemFailures\n\nThis will make it so that when you lock the record, it returns to the queue only the record that was locked.\n\nBelow is an example of SQS lambda function configuration:\n\n```yaml\nlambda-function:\n  handler: src/function.handler\n  events:\n    - sqs:\n        batchSize: 6\n        functionResponseTypes: ReportBatchItemFailures\n        arn:\n          Fn::GetAtt:\n            - Queue\n            - Arn\n```\n\n## Parameters\n\n- `prefix (required)` - Prefix for mounting the key in the registry lock\n- `param (required)` - Name of the parameter that will be retrieved from the request to be used as a registry lock key\n- `connection (required)` - Redis client connection that will be used by redlock\n- `ttl (optional)` - Lock expiration time, if not informed the default is 7500\n- `options (optional)` - Redlock options configuration for more information on the options see the redlock doc [here](https://github.com/mike-marcacci/node-redlock). Default value if not informed is:\n\n```typescript\n{\ndriftFactor: 0.1,\nretryCount: 1,\n};\n```\n\n## Run test\n\nTo run the unit tests, run following command\n\n```bash\n  npm run test\n```\n\n## Libraries\n\nUsed:\n\n- [redlock](https://github.com/mike-marcacci/node-redlock)\n\nDependence:\n\n- [Middy](https://github.com/middyjs/middy)\n- [ioredis](https://github.com/luin/ioredis)\n\nObs: if you have an installation problem of not having the redlock library, you will have to install it in your project\n\n## Credits\n\nCreated by [@fzanfolim](https://github.com/fzanfolim) in OmniChat Squad Bot\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomnichat%2Fmiddy-lock-redis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomnichat%2Fmiddy-lock-redis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomnichat%2Fmiddy-lock-redis/lists"}