{"action":"created","comment":{"url":"https://api.github.com/repos/openresty/lua-resty-lock/pulls/comments/46773224","id":46773224,"diff_hunk":"@@ -468,3 +468,76 @@ lock 2: unlock: nil, unlocked\n --- no_error_log\n [error]\n \n+\n+\n+=== TEST 14: serial lock and unlock with safe_add\n+--- http_config eval: $::HttpConfig\n+--- config\n+    location = /t {\n+        content_by_lua '\n+            local lock = require \"resty.lock\"\n+            for i = 1, 2 do\n+                local lock = lock:new(\"cache_locks\", {safe_add = true})\n+                local elapsed, err = lock:lock(\"foo\")\n+                ngx.say(\"lock: \", elapsed, \", \", err)\n+                local ok, err = lock:unlock()\n+                if not ok then\n+                    ngx.say(\"failed to unlock: \", err)\n+                end\n+                ngx.say(\"unlock: \", ok)\n+            end\n+        ';\n+    }\n+--- request\n+GET /t\n+--- response_body\n+lock: 0, nil\n+unlock: 1\n+lock: 0, nil\n+unlock: 1\n+\n+--- no_error_log\n+[error]\n+\n+\n+\n+=== TEST 15: use safe_add, dont have enough memory\n+--- http_config eval: $::HttpConfig\n+--- config\n+    location = /t {\n+        content_by_lua '\n+            local lock  = require \"resty.lock\"\n+            local cache = ngx.shared.cache_locks\n+\n+            cache:flush_all()\n+            function full_dict( dict )\n+                for i=1,10000 do","path":"t/sanity.t","position":47,"original_position":47,"commit_id":"f9883111269d535b1e0f50b1fff5f0c3458bf26d","original_commit_id":"f9883111269d535b1e0f50b1fff5f0c3458bf26d","user":{"login":"agentzh","id":56241,"avatar_url":"https://avatars.githubusercontent.com/u/56241?v=3","gravatar_id":"","url":"https://api.github.com/users/agentzh","html_url":"https://github.com/agentzh","followers_url":"https://api.github.com/users/agentzh/followers","following_url":"https://api.github.com/users/agentzh/following{/other_user}","gists_url":"https://api.github.com/users/agentzh/gists{/gist_id}","starred_url":"https://api.github.com/users/agentzh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agentzh/subscriptions","organizations_url":"https://api.github.com/users/agentzh/orgs","repos_url":"https://api.github.com/users/agentzh/repos","events_url":"https://api.github.com/users/agentzh/events{/privacy}","received_events_url":"https://api.github.com/users/agentzh/received_events","type":"User","site_admin":false},"body":"style: need spaces around the binary operator `=` and one space after `,`. The preferred form is\r\n\r\n```lua\r\nfor i = 1, 10000 do\r\n```","created_at":"2015-12-06T17:33:35Z","updated_at":"2015-12-06T17:33:35Z","html_url":"https://github.com/openresty/lua-resty-lock/pull/6#discussion_r46773224","pull_request_url":"https://api.github.com/repos/openresty/lua-resty-lock/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/openresty/lua-resty-lock/pulls/comments/46773224"},"html":{"href":"https://github.com/openresty/lua-resty-lock/pull/6#discussion_r46773224"},"pull_request":{"href":"https://api.github.com/repos/openresty/lua-resty-lock/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/openresty/lua-resty-lock/pulls/6","id":52634071,"html_url":"https://github.com/openresty/lua-resty-lock/pull/6","diff_url":"https://github.com/openresty/lua-resty-lock/pull/6.diff","patch_url":"https://github.com/openresty/lua-resty-lock/pull/6.patch","issue_url":"https://api.github.com/repos/openresty/lua-resty-lock/issues/6","number":6,"state":"open","locked":false,"title":"keep the key never overrides","user":{"login":"membphis","id":6814606,"avatar_url":"https://avatars.githubusercontent.com/u/6814606?v=3","gravatar_id":"","url":"https://api.github.com/users/membphis","html_url":"https://github.com/membphis","followers_url":"https://api.github.com/users/membphis/followers","following_url":"https://api.github.com/users/membphis/following{/other_user}","gists_url":"https://api.github.com/users/membphis/gists{/gist_id}","starred_url":"https://api.github.com/users/membphis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/membphis/subscriptions","organizations_url":"https://api.github.com/users/membphis/orgs","repos_url":"https://api.github.com/users/membphis/repos","events_url":"https://api.github.com/users/membphis/events{/privacy}","received_events_url":"https://api.github.com/users/membphis/received_events","type":"User","site_admin":false},"body":"never overrides the (least recently used) unexpired items in the store\nwhen running out of storage in the shared memory zone","created_at":"2015-12-04T06:20:53Z","updated_at":"2015-12-06T17:33:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"df5af6760bf86756e3ff477c4d41c6545a868bfb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openresty/lua-resty-lock/pulls/6/commits","review_comments_url":"https://api.github.com/repos/openresty/lua-resty-lock/pulls/6/comments","review_comment_url":"https://api.github.com/repos/openresty/lua-resty-lock/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openresty/lua-resty-lock/issues/6/comments","statuses_url":"https://api.github.com/repos/openresty/lua-resty-lock/statuses/f9883111269d535b1e0f50b1fff5f0c3458bf26d","head":{"label":"membphis:bugfix","ref":"bugfix","sha":"f9883111269d535b1e0f50b1fff5f0c3458bf26d","user":{"login":"membphis","id":6814606,"avatar_url":"https://avatars.githubusercontent.com/u/6814606?v=3","gravatar_id":"","url":"https://api.github.com/users/membphis","html_url":"https://github.com/membphis","followers_url":"https://api.github.com/users/membphis/followers","following_url":"https://api.github.com/users/membphis/following{/other_user}","gists_url":"https://api.github.com/users/membphis/gists{/gist_id}","starred_url":"https://api.github.com/users/membphis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/membphis/subscriptions","organizations_url":"https://api.github.com/users/membphis/orgs","repos_url":"https://api.github.com/users/membphis/repos","events_url":"https://api.github.com/users/membphis/events{/privacy}","received_events_url":"https://api.github.com/users/membphis/received_events","type":"User","site_admin":false},"repo":{"id":47384824,"name":"lua-resty-lock","full_name":"membphis/lua-resty-lock","owner":{"login":"membphis","id":6814606,"avatar_url":"https://avatars.githubusercontent.com/u/6814606?v=3","gravatar_id":"","url":"https://api.github.com/users/membphis","html_url":"https://github.com/membphis","followers_url":"https://api.github.com/users/membphis/followers","following_url":"https://api.github.com/users/membphis/following{/other_user}","gists_url":"https://api.github.com/users/membphis/gists{/gist_id}","starred_url":"https://api.github.com/users/membphis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/membphis/subscriptions","organizations_url":"https://api.github.com/users/membphis/orgs","repos_url":"https://api.github.com/users/membphis/repos","events_url":"https://api.github.com/users/membphis/events{/privacy}","received_events_url":"https://api.github.com/users/membphis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/membphis/lua-resty-lock","description":"Simple nonblocking lock API for ngx_lua based on shared memory dictionaries","fork":true,"url":"https://api.github.com/repos/membphis/lua-resty-lock","forks_url":"https://api.github.com/repos/membphis/lua-resty-lock/forks","keys_url":"https://api.github.com/repos/membphis/lua-resty-lock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/membphis/lua-resty-lock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/membphis/lua-resty-lock/teams","hooks_url":"https://api.github.com/repos/membphis/lua-resty-lock/hooks","issue_events_url":"https://api.github.com/repos/membphis/lua-resty-lock/issues/events{/number}","events_url":"https://api.github.com/repos/membphis/lua-resty-lock/events","assignees_url":"https://api.github.com/repos/membphis/lua-resty-lock/assignees{/user}","branches_url":"https://api.github.com/repos/membphis/lua-resty-lock/branches{/branch}","tags_url":"https://api.github.com/repos/membphis/lua-resty-lock/tags","blobs_url":"https://api.github.com/repos/membphis/lua-resty-lock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/membphis/lua-resty-lock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/membphis/lua-resty-lock/git/refs{/sha}","trees_url":"https://api.github.com/repos/membphis/lua-resty-lock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/membphis/lua-resty-lock/statuses/{sha}","languages_url":"https://api.github.com/repos/membphis/lua-resty-lock/languages","stargazers_url":"https://api.github.com/repos/membphis/lua-resty-lock/stargazers","contributors_url":"https://api.github.com/repos/membphis/lua-resty-lock/contributors","subscribers_url":"https://api.github.com/repos/membphis/lua-resty-lock/subscribers","subscription_url":"https://api.github.com/repos/membphis/lua-resty-lock/subscription","commits_url":"https://api.github.com/repos/membphis/lua-resty-lock/commits{/sha}","git_commits_url":"https://api.github.com/repos/membphis/lua-resty-lock/git/commits{/sha}","comments_url":"https://api.github.com/repos/membphis/lua-resty-lock/comments{/number}","issue_comment_url":"https://api.github.com/repos/membphis/lua-resty-lock/issues/comments{/number}","contents_url":"https://api.github.com/repos/membphis/lua-resty-lock/contents/{+path}","compare_url":"https://api.github.com/repos/membphis/lua-resty-lock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/membphis/lua-resty-lock/merges","archive_url":"https://api.github.com/repos/membphis/lua-resty-lock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/membphis/lua-resty-lock/downloads","issues_url":"https://api.github.com/repos/membphis/lua-resty-lock/issues{/number}","pulls_url":"https://api.github.com/repos/membphis/lua-resty-lock/pulls{/number}","milestones_url":"https://api.github.com/repos/membphis/lua-resty-lock/milestones{/number}","notifications_url":"https://api.github.com/repos/membphis/lua-resty-lock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/membphis/lua-resty-lock/labels{/name}","releases_url":"https://api.github.com/repos/membphis/lua-resty-lock/releases{/id}","created_at":"2015-12-04T06:04:33Z","updated_at":"2015-12-04T06:04:34Z","pushed_at":"2015-12-06T05:43:52Z","git_url":"git://github.com/membphis/lua-resty-lock.git","ssh_url":"git@github.com:membphis/lua-resty-lock.git","clone_url":"https://github.com/membphis/lua-resty-lock.git","svn_url":"https://github.com/membphis/lua-resty-lock","homepage":null,"size":32,"stargazers_count":0,"watchers_count":0,"language":"Lua","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"openresty:master","ref":"master","sha":"08e5f0779a416986f2bf1a3efc08b151885de9fb","user":{"login":"openresty","id":7390180,"avatar_url":"https://avatars.githubusercontent.com/u/7390180?v=3","gravatar_id":"","url":"https://api.github.com/users/openresty","html_url":"https://github.com/openresty","followers_url":"https://api.github.com/users/openresty/followers","following_url":"https://api.github.com/users/openresty/following{/other_user}","gists_url":"https://api.github.com/users/openresty/gists{/gist_id}","starred_url":"https://api.github.com/users/openresty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openresty/subscriptions","organizations_url":"https://api.github.com/users/openresty/orgs","repos_url":"https://api.github.com/users/openresty/repos","events_url":"https://api.github.com/users/openresty/events{/privacy}","received_events_url":"https://api.github.com/users/openresty/received_events","type":"Organization","site_admin":false},"repo":{"id":13136767,"name":"lua-resty-lock","full_name":"openresty/lua-resty-lock","owner":{"login":"openresty","id":7390180,"avatar_url":"https://avatars.githubusercontent.com/u/7390180?v=3","gravatar_id":"","url":"https://api.github.com/users/openresty","html_url":"https://github.com/openresty","followers_url":"https://api.github.com/users/openresty/followers","following_url":"https://api.github.com/users/openresty/following{/other_user}","gists_url":"https://api.github.com/users/openresty/gists{/gist_id}","starred_url":"https://api.github.com/users/openresty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openresty/subscriptions","organizations_url":"https://api.github.com/users/openresty/orgs","repos_url":"https://api.github.com/users/openresty/repos","events_url":"https://api.github.com/users/openresty/events{/privacy}","received_events_url":"https://api.github.com/users/openresty/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openresty/lua-resty-lock","description":"Simple nonblocking lock API for ngx_lua based on shared memory dictionaries","fork":false,"url":"https://api.github.com/repos/openresty/lua-resty-lock","forks_url":"https://api.github.com/repos/openresty/lua-resty-lock/forks","keys_url":"https://api.github.com/repos/openresty/lua-resty-lock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openresty/lua-resty-lock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openresty/lua-resty-lock/teams","hooks_url":"https://api.github.com/repos/openresty/lua-resty-lock/hooks","issue_events_url":"https://api.github.com/repos/openresty/lua-resty-lock/issues/events{/number}","events_url":"https://api.github.com/repos/openresty/lua-resty-lock/events","assignees_url":"https://api.github.com/repos/openresty/lua-resty-lock/assignees{/user}","branches_url":"https://api.github.com/repos/openresty/lua-resty-lock/branches{/branch}","tags_url":"https://api.github.com/repos/openresty/lua-resty-lock/tags","blobs_url":"https://api.github.com/repos/openresty/lua-resty-lock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openresty/lua-resty-lock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openresty/lua-resty-lock/git/refs{/sha}","trees_url":"https://api.github.com/repos/openresty/lua-resty-lock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openresty/lua-resty-lock/statuses/{sha}","languages_url":"https://api.github.com/repos/openresty/lua-resty-lock/languages","stargazers_url":"https://api.github.com/repos/openresty/lua-resty-lock/stargazers","contributors_url":"https://api.github.com/repos/openresty/lua-resty-lock/contributors","subscribers_url":"https://api.github.com/repos/openresty/lua-resty-lock/subscribers","subscription_url":"https://api.github.com/repos/openresty/lua-resty-lock/subscription","commits_url":"https://api.github.com/repos/openresty/lua-resty-lock/commits{/sha}","git_commits_url":"https://api.github.com/repos/openresty/lua-resty-lock/git/commits{/sha}","comments_url":"https://api.github.com/repos/openresty/lua-resty-lock/comments{/number}","issue_comment_url":"https://api.github.com/repos/openresty/lua-resty-lock/issues/comments{/number}","contents_url":"https://api.github.com/repos/openresty/lua-resty-lock/contents/{+path}","compare_url":"https://api.github.com/repos/openresty/lua-resty-lock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openresty/lua-resty-lock/merges","archive_url":"https://api.github.com/repos/openresty/lua-resty-lock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openresty/lua-resty-lock/downloads","issues_url":"https://api.github.com/repos/openresty/lua-resty-lock/issues{/number}","pulls_url":"https://api.github.com/repos/openresty/lua-resty-lock/pulls{/number}","milestones_url":"https://api.github.com/repos/openresty/lua-resty-lock/milestones{/number}","notifications_url":"https://api.github.com/repos/openresty/lua-resty-lock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openresty/lua-resty-lock/labels{/name}","releases_url":"https://api.github.com/repos/openresty/lua-resty-lock/releases{/id}","created_at":"2013-09-26T23:28:50Z","updated_at":"2015-12-06T11:26:15Z","pushed_at":"2015-12-06T05:43:52Z","git_url":"git://github.com/openresty/lua-resty-lock.git","ssh_url":"git@github.com:openresty/lua-resty-lock.git","clone_url":"https://github.com/openresty/lua-resty-lock.git","svn_url":"https://github.com/openresty/lua-resty-lock","homepage":null,"size":31,"stargazers_count":53,"watchers_count":53,"language":"Lua","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":2,"forks":18,"open_issues":2,"watchers":53,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openresty/lua-resty-lock/pulls/6"},"html":{"href":"https://github.com/openresty/lua-resty-lock/pull/6"},"issue":{"href":"https://api.github.com/repos/openresty/lua-resty-lock/issues/6"},"comments":{"href":"https://api.github.com/repos/openresty/lua-resty-lock/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/openresty/lua-resty-lock/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/openresty/lua-resty-lock/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openresty/lua-resty-lock/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/openresty/lua-resty-lock/statuses/f9883111269d535b1e0f50b1fff5f0c3458bf26d"}}}}