{"action":"created","issue":{"url":"https://api.github.com/repos/CodisLabs/codis/issues/950","repository_url":"https://api.github.com/repos/CodisLabs/codis","labels_url":"https://api.github.com/repos/CodisLabs/codis/issues/950/labels{/name}","comments_url":"https://api.github.com/repos/CodisLabs/codis/issues/950/comments","events_url":"https://api.github.com/repos/CodisLabs/codis/issues/950/events","html_url":"https://github.com/CodisLabs/codis/issues/950","id":175760705,"number":950,"title":"关于key到slot的路由计算","user":{"login":"lingshengjie","id":21969457,"avatar_url":"https://avatars.githubusercontent.com/u/21969457?v=3","gravatar_id":"","url":"https://api.github.com/users/lingshengjie","html_url":"https://github.com/lingshengjie","followers_url":"https://api.github.com/users/lingshengjie/followers","following_url":"https://api.github.com/users/lingshengjie/following{/other_user}","gists_url":"https://api.github.com/users/lingshengjie/gists{/gist_id}","starred_url":"https://api.github.com/users/lingshengjie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lingshengjie/subscriptions","organizations_url":"https://api.github.com/users/lingshengjie/orgs","repos_url":"https://api.github.com/users/lingshengjie/repos","events_url":"https://api.github.com/users/lingshengjie/events{/privacy}","received_events_url":"https://api.github.com/users/lingshengjie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-08T13:57:10Z","updated_at":"2016-09-08T13:59:36Z","closed_at":null,"body":"希望了解key到slot的路由计算过程，但是发现下列代码计算slot时，入参并不是在命令行中敲入的key。\r\n比如执行```set key123 value123```时，入参的key是什么？是怎么处理的？\r\n并请告知处理的代码在哪，多谢。\r\n\r\n```code\r\nfunc hashSlot(key []byte) int {\r\n\tconst (\r\n\t\tTagBeg = '{'\r\n\t\tTagEnd = '}'\r\n\t)\r\n\tif beg := bytes.IndexByte(key, TagBeg); beg >= 0 {\r\n\t\tif end := bytes.IndexByte(key[beg+1:], TagEnd); end >= 0 {\r\n\t\t\tkey = key[beg+1 : beg+1+end]\r\n\t\t}\r\n\t}\r\n\treturn int(crc32.ChecksumIEEE(key) % models.MaxSlotNum)\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/CodisLabs/codis/issues/comments/245606242","html_url":"https://github.com/CodisLabs/codis/issues/950#issuecomment-245606242","issue_url":"https://api.github.com/repos/CodisLabs/codis/issues/950","id":245606242,"user":{"login":"spinlock","id":722853,"avatar_url":"https://avatars.githubusercontent.com/u/722853?v=3","gravatar_id":"","url":"https://api.github.com/users/spinlock","html_url":"https://github.com/spinlock","followers_url":"https://api.github.com/users/spinlock/followers","following_url":"https://api.github.com/users/spinlock/following{/other_user}","gists_url":"https://api.github.com/users/spinlock/gists{/gist_id}","starred_url":"https://api.github.com/users/spinlock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spinlock/subscriptions","organizations_url":"https://api.github.com/users/spinlock/orgs","repos_url":"https://api.github.com/users/spinlock/repos","events_url":"https://api.github.com/users/spinlock/events{/privacy}","received_events_url":"https://api.github.com/users/spinlock/received_events","type":"User","site_admin":false},"created_at":"2016-09-08T13:59:36Z","updated_at":"2016-09-08T13:59:36Z","body":"https://github.com/CodisLabs/codis/blob/dev3.1/pkg/proxy/mapper.go#L273\r\n这是 3.1 的代码，和其他分支只是文件位置不太一样。不过都在 mapper.go 里面。\r\n\r\n这个 key 是根据指令计算得到的。大多数指令选择命令后的第一个参数，个别指令选择第二个。"}}
{"actor":{"display_login":"spinlock"}}