{"action":"created","issue":{"url":"https://api.github.com/repos/cloudwu/skynet/issues/376","labels_url":"https://api.github.com/repos/cloudwu/skynet/issues/376/labels{/name}","comments_url":"https://api.github.com/repos/cloudwu/skynet/issues/376/comments","events_url":"https://api.github.com/repos/cloudwu/skynet/issues/376/events","html_url":"https://github.com/cloudwu/skynet/pull/376","id":116672914,"number":376,"title":"redis pipeline v2(support function as pipeline params)","user":{"login":"gitfancode","id":5878346,"avatar_url":"https://avatars.githubusercontent.com/u/5878346?v=3","gravatar_id":"","url":"https://api.github.com/users/gitfancode","html_url":"https://github.com/gitfancode","followers_url":"https://api.github.com/users/gitfancode/followers","following_url":"https://api.github.com/users/gitfancode/following{/other_user}","gists_url":"https://api.github.com/users/gitfancode/gists{/gist_id}","starred_url":"https://api.github.com/users/gitfancode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitfancode/subscriptions","organizations_url":"https://api.github.com/users/gitfancode/orgs","repos_url":"https://api.github.com/users/gitfancode/repos","events_url":"https://api.github.com/users/gitfancode/events{/privacy}","received_events_url":"https://api.github.com/users/gitfancode/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-13T00:24:32Z","updated_at":"2015-11-13T03:34:50Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/cloudwu/skynet/pulls/376","html_url":"https://github.com/cloudwu/skynet/pull/376","diff_url":"https://github.com/cloudwu/skynet/pull/376.diff","patch_url":"https://github.com/cloudwu/skynet/pull/376.patch"},"body":"可以在非redis服务(例如在玩家agent中)内封装\n\n```lua\ndb.pipelining = function (self, block)\n\tlocal ops = {}\n\n\tblock(setmetatable({}, {\n\t\t__index = function (_, name)\n\t\t\treturn function (_, ...)\n\t\t\t\ttable.insert(ops, {name, ...})\n\t\t\tend\n\t\tend\n\t}))\n\n\treturn self:pipeline(ops)\nend\n```\n\n这样就可以实现\n\n```lua\ndb:pipelining(function (red)\n\tred:hincrby(\"hello\", 1, 1)\n\tred:del(\"hello\")\n\tred:hmset(\"hello\", 1, 1, 2, 2, 3, 3)\n\tred:hgetall(\"hello\")\nend)\n```"},"comment":{"url":"https://api.github.com/repos/cloudwu/skynet/issues/comments/156312820","html_url":"https://github.com/cloudwu/skynet/pull/376#issuecomment-156312820","issue_url":"https://api.github.com/repos/cloudwu/skynet/issues/376","id":156312820,"user":{"login":"gitfancode","id":5878346,"avatar_url":"https://avatars.githubusercontent.com/u/5878346?v=3","gravatar_id":"","url":"https://api.github.com/users/gitfancode","html_url":"https://github.com/gitfancode","followers_url":"https://api.github.com/users/gitfancode/followers","following_url":"https://api.github.com/users/gitfancode/following{/other_user}","gists_url":"https://api.github.com/users/gitfancode/gists{/gist_id}","starred_url":"https://api.github.com/users/gitfancode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitfancode/subscriptions","organizations_url":"https://api.github.com/users/gitfancode/orgs","repos_url":"https://api.github.com/users/gitfancode/repos","events_url":"https://api.github.com/users/gitfancode/events{/privacy}","received_events_url":"https://api.github.com/users/gitfancode/received_events","type":"User","site_admin":false},"created_at":"2015-11-13T03:34:50Z","updated_at":"2015-11-13T03:34:50Z","body":"我写成table.concat(cmds) 这样也能保证正确运行 "}}