{"id":25711288,"url":"https://github.com/cnuggets/nlockjs","last_synced_at":"2026-04-11T21:04:22.409Z","repository":{"id":203014777,"uuid":"708622110","full_name":"cnuggets/nlockjs","owner":"cnuggets","description":"Node.js distributed lock based on Redis","archived":false,"fork":false,"pushed_at":"2023-10-23T06:00:08.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-04-23T22:10:21.477Z","etag":null,"topics":["distributed","nodejs","redis-based-lock"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/cnuggets.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2023-10-23T03:20:28.000Z","updated_at":"2023-10-23T06:08:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"98918bdc-ed57-4cfc-b3e8-9d967830d96e","html_url":"https://github.com/cnuggets/nlockjs","commit_stats":null,"previous_names":["cnuggets/nlockjs"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnuggets%2Fnlockjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnuggets%2Fnlockjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnuggets%2Fnlockjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnuggets%2Fnlockjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cnuggets","download_url":"https://codeload.github.com/cnuggets/nlockjs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240643538,"owners_count":19834252,"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":["distributed","nodejs","redis-based-lock"],"created_at":"2025-02-25T10:25:56.907Z","updated_at":"2026-04-11T21:04:22.315Z","avatar_url":"https://github.com/cnuggets.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nlockjs\nNode.js distributed lock based on Redis\n## Getting Started\n### Download\n```\nnpm install nlockjs\n```\n### Usage\n#### Redis lock\n```\nvar Lock = require(\"nlockjs\").Lock;\n\n// New redis lock\nvar l = new Lock(15, {\n    endpoints: \"localhost:6379\", // Redis endpoints\n    password: \"\"                 // Redis password\n});\n\n// Lock\nl.lock(key).then(function (ok) {\n    // If has lock\n    l.hasLock(key).then(function (yes) {\n        assert.equal(yes, true);\n        \n        // Unlock\n        l.unlock(key).then(function(ok) {\n            assert.equal(ok, true);\n        }, function(err) {\n            console.error(err.toString());\n        });\n    }, function (err) {\n        console.error(err.toString());\n    });\n}, function (err) {\n    console.error(err.toString());\n});\n\n```\n#### Lock with waiting time\n```\n// Lock waiting for 5 seconds\nl.lockWait(key, 5).then(function (ok) {\n    assert.equal(ok, true);\n}, function (err) {\n    console.error(err.toString());\n});\n\n```\n### Methods\n```\n- lock(key)                       // lock\n```\n```\n- lockWait(key, seconds)          // lock with waiting time\n```\n```\n- isLocked(key)                   // check if locked\n```\n```\n- hasLock(key)                    // check if has/own lock\n```\n```\n- Unlock(key)                     // unlock\n```\n\n## License\n\nnlockjs is under the MIT license. See the [LICENSE](LICENSE) for detail.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnuggets%2Fnlockjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcnuggets%2Fnlockjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnuggets%2Fnlockjs/lists"}