{"id":428298,"date":"2021-04-18T02:50:45","date_gmt":"2021-04-17T18:50:45","guid":{"rendered":"http:\/\/4563.org\/?p=428298"},"modified":"2021-04-18T02:50:45","modified_gmt":"2021-04-17T18:50:45","slug":"map-%e7%9a%84%e4%b8%80%e4%b8%aa%e7%a5%9e%e5%a5%87%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=428298","title":{"rendered":"map \u7684\u4e00\u4e2a\u795e\u5947\u7684\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  map \u7684\u4e00\u4e2a\u795e\u5947\u7684\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <span><i><\/i> 9<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4f7f\u7528\u4e0b\u9762\u7684\u4e00\u6bb5\u4ee3\u7801\u6765\u7edf\u8ba1\u94fe\u63a5\u7684\u8bbf\u95ee\u60c5\u51b5\uff0c\u4f7f\u7528\u65b9\u6cd5\u5c31\u662f\u7528 Incr \u6bcf\u6b21\u8bbf\u95ee\u52a0 1 \u5355\u72ec\u6d4b\u8bd5\u7684\u65f6\u5019\uff0c\u6bd4\u5982\u7528 wrk \u6765\u538b\u6d4b\u90fd\u633a\u6b63\u5e38\u7684 \u795e\u5947\u7684\u662f\uff0c\u4e00\u6362\u6210 nginx\uff0cc.data \u91cc\u9762\u7684 key \u5c31\u53d8\u5f97\u4e0d\u6b63\u5e38\uff0c\u628a\u4ed6\u6253\u5370\u51fa\u6765\uff0c\u53d1\u73b0\u6709\u5f88\u591a\u76f8\u540c\u7684 key \u6bd4\u5982\u672c\u6765\u5c31\u53ea\u6709\u4e00\u4e2a key \u7684\uff0c\u4ed6\u4f1a\u51fa\u73b0 key: 1, key: 2, key: 1, key: 1 \u8fd9\u79cd\uff0c\u641e\u4e0d\u61c2\u3002\u3002\u3002<\/p>\n<pre><code>type Counter struct {  sync.RWMutex  data map[string]int }  func (c *Counter) Get(key string) int {  c.RLock()  count := c.data[key]  c.RUnlock()  return count }  func (c *Counter) Incr(key string) int {  c.Lock()  c.data[key]++  count := c.data[key]  c.Unlock()  return count }  func (c *Counter) Delete(key string) {  c.Lock()  delete(c.data, key)  c.Unlock() } <\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>76<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5666359\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : skiy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             &#8220;`defer c.RUnlock()&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666360\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yuguorui96 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u7684 nginx \u4e0d\u4f1a\u662f fork \u5427\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666361\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @yuguorui96 nginx \u662f\u591a\u8fdb\u7a0b\uff0c\u4f46\u662f\u8fd9\u4e2a go \u7684\u540e\u7aef\u53ea\u6709\u4e00\u4e2a\uff0c\u5e94\u8be5\u6ca1\u5f71\u54cd\u554a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666362\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @skiy \u8fd9\u4e2a\u4ee3\u7801\u7b80\u6d01\u4e86\u4e00\u70b9~\u6027\u80fd\u4e0b\u964d\u4e86\u4e00\u70b9~                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666363\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : no1xsyzy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u81f3\u5c11\u8fd9\u91cc\u770b\u4e0d\u51fa\u4ec0\u4e48\u95ee\u9898<br \/>\u80fd\u63d0\u4f9b\u6700\u5c0f\u53ef\u590d\u73b0\u6837\u672c\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666364\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : sujin190 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             map \u4e0d\u53ef\u80fd\u591a\u4e2a key \u7684\uff0c\u53cd\u5e38\u89c4\u7684\u8bdd\u4e5f\u8bb8\u662f\u4e0d\u53ef\u89c1\u5b57\u7b26\uff1f\u8981\u4e48\u5c31\u662f\u4f60\u8f93\u51fa\u4ee3\u7801\u6709\u95ee\u9898                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666365\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : GTim <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             show \u4f60\u7684\u5b8c\u6574\u6d4b\u8bd5\u4ee3\u7801                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666366\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : AngryPanda <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u76f2\u731c\u8fd9\u4e9b key \u5728\u4e0d\u540c\u534f\u7a0b\u4e2d                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666367\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Lpl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u8fd9\u6bb5\u4ee3\u7801\u69fd\u70b9\u6bd4\u8f83\u591a\uff0c\u6027\u80fd\u4f1a\u5f88\u5dee\uff1a<br \/>1. \u53ef\u4ee5\u8003\u8651\u7528 atomic \u800c\u4e0d\u662f\u7528\u9501<br \/>2. \u53ef\u4ee5\u8003\u8651\u7528\u7ba1\u9053\u6765\u505a Producer-Consumer\uff0c\u7136\u540e\u591a\u4e2a\u534f\u7a0b\u6d88\u8d39\uff0c\u800c\u4e0d\u662f\u8003\u8651\u7528\u9501<br \/>3. \u5b9e\u5728\u60f3\u52a0\u9501\uff0c\u5c31\u7ed9\u67d0\u4e2a key \u52a0\u9501\uff0c\u800c\u4e0d\u662f\u7ed9 Counter \u5bf9\u8c61\u52a0\u9501\u3002\u9501\u7684\u7c92\u5ea6\u592a\u7c97\u4e86<\/p>\n<p>\u7ed9\u4e2a\u6bd4\u8f83\u5b8c\u6574\u7684\u4ee3\u7801\u770b\u770b                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666368\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Lpl \u6279\u8bc4\u7684\u5bf9                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666369\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @AngryPanda \u6309\u7406\u52a0\u4e86\u9501\u5e94\u8be5\u4e0d\u540c\u7684\u534f\u7a0b\u4e5f\u662f OK \u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666370\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @no1xsyzy <br \/>@GTim <\/p>\n<p>\u8865\u5728\u540e\u9762\u4e86\uff0c\u770b\u770b\u80fd\u4e0d\u80fd\u53d1\u73b0\u4ec0\u4e48\u95ee\u9898                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666371\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Lpl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8111\u888b\u75bc..\u4f60\u8fd9\u4e2a\u95ee\u9898\u51fa\u5728 init \u91cc\u8fb9\u7684\u90a3\u4e2a\u534f\u7a0b\u4e86\uff1a<br \/>accessLog = Counter{data: make(map[string]int)}<\/p>\n<p>\u91cc\u8fb9\u591a\u4e86\u8fd9\u53e5\u8bdd\uff0c\u6211\u7406\u89e3\u4f60\u8fd9\u4e2a\u534f\u7a0b\u5c31\u662f\u60f3\u6253\u5370\u4e0b\u5f53\u524d\u5df2\u5b58\u5728\u7684\u6570\u636e\uff1f                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666372\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : makdon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Lpl \u6211\u7406\u89e3\u4ed6\u8fd9\u91cc\u7684\u610f\u601d\u662f\uff0c\u5148\u4fdd\u5b58\u4e0b\u6765\u5f53\u524d\u7684\u72b6\u6001\uff0c\u7136\u540e\u91cd\u7f6e counter<br \/>\u8fd9\u91cc\u7684\u95ee\u9898\u6211\u7406\u89e3\u53ea\u662f\u91cd\u7f6e\u5168\u5c40 counter \u7684\u65f6\u5019\u6ca1\u6709\u52a0\u9501\uff0c\u6240\u4ee5\u4f1a\u4e22\u5931\u90e8\u5206\u7edf\u8ba1\u6570\u636e\uff0c\u4f46\u662f\u4e0d\u5e94\u8be5\u4f1a\u5982\u4e3b\u6240\u8bf4\u201c\u8fd9\u91cc abcde \u5c31\u662f\u76f8\u540c\u7684\u201d<\/p>\n<p>\u6211 review \u4e3b\u7684\u4ee3\u7801\u6ca1\u6709 review \u51fa\u5565\u95ee\u9898, \u590d\u73b0\u7684\u6210\u672c\u5bf9\u6211\u6765\u8bf4\u6709\u70b9\u9ad8\u3002<br \/>\u5982\u679c\u6309\u7167\u201c\u8fd9\u91cc abcde \u5c31\u662f\u76f8\u540c\u7684\u201d \u8fd9\u91cc\u6765\u63a8\u65ad\uff0c\u56e0\u4e3a map \u91cc\u9762\u7684 key \u503c\u90fd\u662f\u552f\u4e00\u7684\uff0c\u6240\u4ee5\u731c\u60f3\u53ef\u80fd\u4e3b\u5b9e\u9645\u4e0a\u4f7f\u7528\u7684\u5e76\u4e0d\u662f map[string]int, \u800c\u662f\u81ea\u5b9a\u4e49\u7684\u7ed3\u6784\u4f53 \/\u6307\u9488 \/\u6d6e\u70b9\u6570<br \/>\u7136\u540e\u591a\u4e2a\u4e0d\u540c\u7684 id\uff0c\u867d\u7136\u5185\u5bb9\u662f\u4e00\u81f4\u7684\uff0c\u4f46\u662f hashkey \u4e0d\u4e00\u81f4                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666373\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @makdon \u4e0d\u662f\u7684\uff0c\u6211\u7528\u7684\u5c31\u662f map[string]int\uff0c\u7edf\u8ba1\u7684\u5c31\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32 id \u7684\u8bbf\u95ee\u6b21\u6570\uff0chashkey \u662f\u4e00\u6837\u7684<br \/>\u8981\u662f\u6b63\u5e38\u6211\u5c31\u4e0d\u95ee\u4e86\uff0c\u95ee\u5c31\u662f\u56e0\u4e3a\u4e0d\u6b63\u5e38                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666374\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Lpl \u8fd9\u4e2a\u53ea\u662f\u4e2a\u7b80\u5316\u7684\u4f8b\u5b50\uff0c\u5b9e\u9645\u4e0a\u8fd8\u9700\u8981\u5904\u7406\u4e00\u4e0b\uff0c\u4e0d\u8fc7\u610f\u601d\u662f\u4e00\u6837\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666375\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : joesonw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             accessLog = Counter{data: make(map[string]int)}<\/p>\n<p>\u6ca1\u52a0\u9501                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666376\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @joesonw \u662f\u8981\u52a0\u4e2a\u9501\uff0c\u4e0d\u8fc7\u4e0d\u662f\u56e0\u4e3a\u8fd9\u4e2a\uff0c\u6211\u8bd5\u8fc7\u628a\u8fd9\u53e5\u6ce8\u91ca\u6389\uff0c\u4e5f\u662f\u4e00\u6837\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666377\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : joesonw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u662f\u6253\u5370\u90a3\u7684\u95ee\u9898\u5417? \u6ca1\u6362\u884c? \u73b0\u5728\u7684\u6253\u5370\u6ca1\u6709\u6253\u5370 map, \u53ea\u6253\u4e86 map \u7684\u957f\u5ea6.                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666378\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @joesonw \u55ef\uff0c\u5c31\u662f\u672c\u6765\u53ea\u8981\u51e0\u767e\u4e2a key \u7684\uff0c\u7ed3\u679c map \u957f\u5ea6\u53ef\u4ee5\u4e0a\u4e07\uff0c\u4e5f\u6253\u5370\u8fc7 map \u672c\u8eab\uff0c\u770b\u5230\u7684\u5c31\u662f\u6709\u91cd\u590d\u7684 key                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666379\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ZSeptember <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u628a\u5b9e\u9645\u91cd\u590d\u7684 key \u53d1\u51fa\u6765\u770b\u770b\uff1f<br \/>\u95ee\u9898\u5e94\u8be5\u8fd8\u662f \u770b\u4f3c\u76f8\u540c\u7684 key \u5b9e\u9645\u4e0d\u540c\uff0c\u4f46\u662f\u5177\u4f53\u4e3a\u4ec0\u4e48\u4e0d\u540c\u5f97\u5177\u4f53\u5206\u6790\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666380\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ZSeptember <br \/>@makdon <br \/>@Lpl <\/p>\n<p>\u5c31\u8fd9\u6837\uff0c\u76f4\u63a5\u6253\u5370 accessLog.data \u7684\u8bdd\uff0c\u6709\u91cd\u590d\u7684 id<br \/>![]( https:\/\/p3-tt-ipv6.byteimg.com\/origin\/pgc-image\/29af76c21c3f4e148252613ab6754a7c)                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666381\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7136\u540e\u5982\u679c\u6253\u5370 tmp \u7684\u8bdd\uff0c\u56e0\u4e3a json \u683c\u5f0f\u5316\u4e4b\u540e\uff0c\u91cd\u590d\u7684 id \u90fd\u53bb\u6389\u4e86\uff0c\u5c31\u4f1a\u53d8\u7684\u7279\u522b\u5c11<br \/>\u8fd9\u4e2a\u56fe\uff0c\u4e0a\u9762\u662f\u6253\u5370 accessLog.data, \u4e0b\u9762\u662f\u6253\u5370 tmp<\/p>\n<p>https:\/\/p26-tt.byteimg.com\/origin\/pgc-image\/55a1b5f43bce43058915b2a74561f1d6                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666382\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : joesonw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u67b7\u9501\u4e86 print accessLog.data?                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666383\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lesismal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             accessLog = Counter{data: make(map[string]int)} <br \/>\u5148\u6539\u6210 <br \/>accessLog = &amp;Counter{data: make(map[string]int)}<br \/>\u5426\u5219\u53ef\u80fd panic<\/p>\n<p>key \u7684\u95ee\u9898\uff0cCounter \u7684 func \u90fd\u628a key \u5148 trim \u4e00\u4e0b<\/p>\n<p>@Lpl <br \/>\u53e6\u5916\uff0c9  3 \u6761\u6ca1\u4e00\u4e2a\u662f\u5bf9\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666384\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lesismal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u987a\u4fbf\u63a8\u4e0b\u81ea\u5df1\u9879\u76ee\uff1a<br \/>https:\/\/v2ex.com\/t\/761727<br \/>https:\/\/v2ex.com\/t\/734682                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666385\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Lpl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @zkdfbb \u6ca1\u9047\u89c1\u8fc7\uff0c\u770b\u4e86 StackOverflow \u4e0a\u6709\u4e2a\u95ee\u9898\u8ddf\u4f60\u8fd9\u4e2a\u6709\u70b9\u50cf\uff1a https:\/\/stackoverflow.com\/questions\/41064208\/go-map-has-duplicate-keys\/41102560<\/p>\n<p>\u770b\u80fd\u5426\u5728 Incr \u7684\u65f6\u5019\uff0c\u6253\u5370\u4e00\u4e0b key \u7684 string \u4e32\uff0c\u518d\u7528 %x \u6253\u5370\u4e00\u4e0b hex \u505a\u4e00\u4e0b\u5bf9\u6bd4\u3002<br \/>\u7136\u540e\u5728\u8f93\u51fa map \u7684\u65f6\u5019\uff0cfor-range \u904d\u5386\u4e0b\uff0c\u4e5f\u7f62 key \u7684 string \u548c hex \u90fd\u6253\u5370\u4e0b\u770b\u770b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666386\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Lpl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lesismal \u80fd\u4e0d\u80fd\u8be6\u7ec6\u5c55\u5f00\u8bf4\u8bf4<br \/>1. atomic \u505a\u7684\u539f\u5b50\u64cd\u4f5c\u662f\u6bd4\u52a0\u9501\u5feb\u5427<br \/>2. \u7528\u7ba1\u9053\u901a\u8fc7\u6c42\u6478\u5efa\u7acb\u591a\u4e2a\u534f\u7a0b\u6765\u6d88\u8d39<br \/>3. \u76ee\u7684\u662f\u4e3a\u4e86\u6bcf\u4e00\u4e2a key \u90fd\u80fd\u5e76\u53d1\u5b89\u5168\uff0c\u52a0\u7ec6\u7c92\u5ea6\u7684\u9501\u4e0d\u7528\u53bb\u52a0\u5bf9\u8c61\u9501\uff0cconcurrentmap \u4e0d\u5c31\u662f\u8fd9\u6837\u505a\u7684\u5417                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666387\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lesismal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Lpl <\/p>\n<p>1. atomic \u505a\u7684\u539f\u5b50\u64cd\u4f5c\u662f\u6bd4\u52a0\u9501\u5feb\u5427<\/p>\n<p>\u5148\u770b 3 \u7684\u56de\u7b54\u5427\uff0c\u56e0\u4e3a\u9501\u4e0d\u53ef\u907f\u514d\uff0c\u6240\u4ee5\u5728\u8fd9\u91cc\u6839\u672c\u4e0d\u80fd\u4f7f\u7528 atomic<\/p>\n<p>\u5e76\u4e14\u56e0\u4e3a\u662f\u6309 map \u7684 key \u8fdb\u884c\u7edf\u8ba1\uff0c\u9996\u5148\u4f60\u5f97\u53d6\u8fd9\u4e2a map key \u5bf9\u5e94\u7684 value\uff0c\u800c\u76f4\u63a5\u53d6 map[key] \u7684\u5730\u5740\u662f\u4e0d\u884c\u7684\uff0c\u4f60\u8bd5\u8bd5\u7f16\u8bd1\u4e0b\uff1a<br \/>m := map[string]int32{&#8220;a&#8221;: 0}<br \/>atomic.AddInt32(&amp;m[&#8220;a&#8221;], 1)<br \/>\u4f1a\u62a5\u9519\uff1a &#8220;cannot take the address of m[&#8220;a&#8221;]&#8221;<\/p>\n<p>2. \u7528\u7ba1\u9053\u901a\u8fc7\u6c42\u6478\u5efa\u7acb\u591a\u4e2a\u534f\u7a0b\u6765\u6d88\u8d39<\/p>\n<p>\u76f8\u5bf9\u6bd4\u8f83\u590d\u6742\u7684\u5e76\u4e14\u9700\u8981\u4fdd\u8bc1\u4e34\u754c\u533a\u4e00\u81f4\u6027\u7684\u5e76\u53d1\u903b\u8f91\u53ef\u4ee5\u8003\u8651\u7528 chan \u66ff\u4ee3\u9501\u6765\u907f\u514d\u9501\u7684\u590d\u6742\u5ea6\u5c24\u5176\u6b7b\u9501\u7b49\u60c5\u51b5\uff0c\u4f46\u662f\u7b80\u5355\u529f\u80fd\uff0c\u5c31\u6bd4\u5982\u8fd9\u79cd\u8ba1\u6570\u5668\uff0c\u4f7f\u7528 chan \u5b9e\u73b0\u8d77\u6765\u4f1a\u6bd4\u9501\u66f4\u9ebb\u70e6\u5e76\u4e14\u6027\u80fd\u7a0d\u5fae\u635f\u5931\u4e00\u70b9\u70b9\uff0c\u5b8c\u5168\u6ca1\u5fc5\u8981\uff0c\u8981\u4ece\u5b9e\u9645\u51fa\u53d1\u3001\u4e0d\u80fd\u7167\u672c\u5ba3\u79d1<\/p>\n<p>3. \u76ee\u7684\u662f\u4e3a\u4e86\u6bcf\u4e00\u4e2a key \u90fd\u80fd\u5e76\u53d1\u5b89\u5168\uff0c\u52a0\u7ec6\u7c92\u5ea6\u7684\u9501\u4e0d\u7528\u53bb\u52a0\u5bf9\u8c61\u9501\uff0cconcurrentmap \u4e0d\u5c31\u662f\u8fd9\u6837\u505a\u7684\u5417<\/p>\n<p>\u9996\u5148\u8981\u89e3\u51b3\u83b7\u5f97\u8fd9\u4e2a key \u7684 value\uff0c\u83b7\u5f97\u8fd9\u4e2a key \u672c\u8eab\u5c31\u9700\u8981\u5bf9 map \u7684\u9501<br \/>\u6807\u51c6\u5e93\u7684 sync.Map \u4e00\u6837\u5185\u7f6e\u9501\u6765\u5b9e\u73b0\u3001\u53ea\u662f\u5e94\u7528\u5c42\u4e0d\u9700\u8981\u81ea\u5df1\u4f7f\u7528\u9501\u7f62\u4e86<br \/>\u5176\u4ed6\u7684\u4e09\u65b9 concurrentmap \u5b9e\u73b0\u4e5f\u5e76\u4e0d\u80fd\u5b9e\u73b0\u6bcf\u4e2a key \u7c92\u5ea6\uff0c\u800c\u662f\u4e3a\u4e86\u51cf\u5c11 key \u6570\u91cf\u5de8\u5927\u65f6\u5e76\u53d1\u6d41\u7684\u7ade\u4e89\uff0c\u6240\u4ee5\u5728\u6807\u51c6\u5e93 map \u4e4b\u4e0a\u518d\u52a0\u4e00\u5c42 hash buckets\uff0c\u518d\u6bcf\u4e2a buckets \u5bf9\u5e94\u7684\u7ed3\u6784\u4e0a\u7528\u4e00\u4e2a\u9501\uff0cgo \u6807\u51c6\u5e93\u81ea\u5df1\u7684 map \u672c\u8eab\u5c31\u662f\u4e2a hash \u4e0b\u9762\u591a\u4e2a buckets\uff0c\u4e09\u65b9 concurrentmap \u76f8\u5f53\u4e8e\u518d\u52a0\u4e00\u5c42 hash \u5206\u5f00\u6210\u591a\u4e2a\u9501\u6765\u964d\u4f4e\u7c92\u5ea6\u4e3a bucket \u7ea7\u522b\u51cf\u5c11\u7ade\u4e89                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666388\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : makdon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Lpl <br \/>\u611f\u89c9\u4f60\u7684 3 \u6761\u602a\u602a\u7684\uff0c\u4f46\u662f\u8bf4\u4e0d\u51fa\u5f88\u5177\u4f53\u5f88\u6709\u8bf4\u670d\u529b\u7684\u7406\u7531\u3002<br \/>\u5c1d\u8bd5\u5217\u4e3e\u4e00\u4e0b\u539f\u56e0\uff1a<br \/>1. map \u662f\u7528\u4e0d\u5230 atomic \u7684\u5427\uff0c\u6ca1\u6709 Google \u5230 atomic \u8ddf map \u4e00\u8d77\u7528\u7684\u65b9\u6cd5\uff0c\u5982\u679c atomic.AddInt32(&amp;m[&#8220;a&#8221;],1) \u4f1a\u62a5\u9519 can not take the address of m[&#8220;id&#8221;],\u3002<br \/>\u5c31\u7b97\u5047\u8bbe\u6211\u4eec\u53ef\u4ee5\u62ff\u5230 addr\uff0c\u90a3\u6211\u4eec\u8fd8\u9700\u8981\u989d\u5916\u5904\u7406 key \u4e0d\u5b58\u5728\u7684\u65f6\u5019\uff0cmap \u6876\u5206\u914d\u7b49\u903b\u8f91\uff0c\u8fd9\u65f6\u5019\u8fd8\u9700\u8981\u4e24\u6b21 hash \uff08\u67e5\u8be2\u662f\u5426\u5b58\u5728\u65f6\u8ba1\u7b97\u4e00\u6b21 hashkey\uff0c\u63d2\u5165 \/\u9012\u589e\u7684\u65f6\u5019\u518d\u8ba1\u7b97\u4e00\u6b21\uff09\u3002hash \u5e94\u8be5\u6bd4\u9501\u91cd\u591a\u4e86\u5427\u3002<\/p>\n<p>2. \u7ba1\u9053\u91cc\u9762\u8fd8\u662f\u5305\u542b\u4e86\u4e00\u4e2a\u9501\uff0c\u53ea\u662f\u662f\u62e5\u6709\u9501\u7684\u65f6\u957f\u53d8\u4e86\uff0c\u4ece\u201chash \u9700\u8981\u7684\u65f6\u95f4\u201d\u53d8\u6210\u4e86\u201c\u5199 channel \u7684\u65f6\u95f4\u201d\uff0c\u4f46\u662f map \u8fd8\u662f\u9700\u8981\u6392\u961f\u5199\u5165\uff0c\u5f15\u5165\u4e2a\u961f\u5217\u76f8\u5f53\u4e8e\u8131\u88e4\u5b50\u653e\u5c41\uff0c\u8fd8\u5f15\u5165\u4e86\u534f\u7a0b\u8c03\u5ea6\u7684\u5f00\u9500\u3002\u5728\u8fd9\u4e2a case \u91cc\u9762\uff0cmap \u5e94\u8be5\u662f\u74f6\u9888\uff0c\u5f15\u5165\u961f\u5217\u5e76\u6ca1\u6709\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n<p>3. \u8fd9\u79cd\u9501\u8bbe\u8ba1\uff0c\u6839\u636e\u5b98\u65b9\u6587\u6863\u201cThe Map type is optimized for two common use cases: (1) when the entry for a given key is only ever written once but read many times, as in caches that only grow, or (2) when multiple goroutines read, write, and overwrite entries for disjoint sets of keys. In these two cases, use of a Map may significantly reduce lock contention compared to a Go map paired with a separate Mutex or RWMutex.\u201d \u5f88\u660e\u663e\u4e0d\u5c5e\u4e8e\u524d\u8005\uff0c\u7136\u540e\u9700\u8981 ++\uff1b\u540e\u8005\u4e5f\u4e0d\u5c5e\u4e8e\uff0c\u56e0\u4e3a id \u5728\u751f\u4ea7\u4e0a\u66f4\u53ef\u80fd\u662f\u5747\u5300\u7684\uff0c\u4e0d\u540c\u534f\u7a0b\u5199\u7684\u503c\u57df\u662f\u6709\u4ea4\u96c6\u7684\uff0c\u4ecd\u7136\u4f1a\u4ea7\u751f\u9501\u7ade\u4e89\uff0c\u6027\u80fd\u4e0d\u4e00\u5b9a\u6bd4 map with RWMutex \u597d                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666389\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lesismal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Lpl <br \/>\u6211\u4e0a\u4e00\u7684\u56de\u7b54\u7684 1 \u4e2d\uff0c\u5373\u4f7f map \u7684 value \u4f7f\u7528\u5bf9\u8c61\uff0c\u7136\u540e atomic \u64cd\u4f5c\u5bf9\u8c61\u7684 value \u4e5f\u4e0d\u9002\u5408\uff0c\u56e0\u4e3a\u6700\u65e9 map \u4e3a\u7a7a\uff0c\u62ff\u4e0d\u5230\u5bf9\u5e94\u7684 value\uff0c\u5982\u679c\u5224\u65ad\u7a7a\u5148\u5b58\u5165\uff0c\u90a3\u8fd8\u662f\u8981\u52a0\u9501\uff0c\u9664\u975e\u4f60\u7684 key \u6570\u91cf\u548c key \u503c\u90fd\u662f\u56fa\u5b9a\u7684\u3001\u521b\u5efa map \u65f6\u5c31\u521d\u59cb\u5316\u4e86 value                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666390\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : makdon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lesismal <br \/>\u51e0\u4e4e\u540c\u65f6\u56de\u590d\u4e86\u540c\u4e00\uff0c\u4e0d\u8fc7\u5927\u4f6c\u4f60\u8bb2\u5f97\u597d\u591a\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666391\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : GTim <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u662f\u9501\u51fa\u4e86\u95ee\u9898\uff0c\u800c\u662f `key` \u51fa\u4e86\u95ee\u9898\uff0c\u53ef\u80fd\u5b58\u5728\u7a7a\u683c\u6216\u8005\u4e0d\u53ef\u89c1\u5b57\u7b26\u7b49                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666392\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Orlion <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             init \u51fd\u6570\u4e2d accessLog = Counter{data: make(map[string]int)}\u8fd9\u53e5\u4ee3\u7801\u4e0d\u662f\u539f\u5b50\u7684\u5427\uff0c\u6362\u6210<br \/>accessLog.Lock()<br \/>accessLog.data = make(map[string]int)<br \/>accessLog.RUnlock()<\/p>\n<p>\u8bd5\u8bd5\u5462\uff1f                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666393\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : love2020 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e00\u4e2a map \u6211 \u77ac\u95f4\u8fdb\u5165\u77e5\u8bc6\u76f2\u533a\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666394\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lesismal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @makdon \u8fc7\u5956\u4e86\uff0c3q                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666395\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lesismal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Orlion \u5bf9\uff0c\u8fd9\u4efd\u4ee3\u7801\u91cc\u95ee\u9898\u6700\u5927\u7684\u5c31\u8fd9\u53e5\uff0caccessLog \u539f\u6765\u7684\u5185\u5b58\u88ab\u8d4b\u4e3a\u65b0\u503c\u7684\u8fc7\u7a0b\u4e0d\u539f\u5b50\uff0c\u6240\u4ee5\u53ef\u80fd panic \u3001\u8fd8\u53ef\u80fd Incr \u7684 Lock \u662f\u539f\u6765\u7684 Mux \u3001Unlock \u662f\u65b0\u7684 Mux \u6240\u4ee5\u6b7b\u9501<\/p>\n<p>\u6211\u8fd8\u662f\u5efa\u8bae\u6211 25 \u8bf4\u7684\u90a3\u6837\u90fd\u6539\u6210 accessLog = &amp;Counter{data: make(map[string]int)}                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666396\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : sxfscool <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             &#8220;`<br \/>func main() {<br \/> m := map[string]int{<br \/> &#8220;abcd&#8221;: 0,<br \/> &#8220;abcdx00&#8221;: 1,<br \/> }<br \/> fmt.Println(m)<br \/>}<br \/>&#8220;`<br \/>\u4f1a\u6253\u5370 map[abcd:0 abcd:1]<br \/>\u8bd5\u4e0b trim \u6389\u7a7a\u767d\u5b57\u7b26\u8bd5\u8bd5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666397\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : sxfscool <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             newString := strings.Map(func(r rune) rune {<br \/> if unicode.IsGraphic(r) {<br \/> return r<br \/> }<br \/> return -1<br \/> }, yourString)<br \/>\u7528\u8fd9\u4e2a\u5904\u7406\u4f60\u7684\u8f93\u5165\u5b57\u7b26\u4e32\u540e\u518d\u653e\u5230 map \u91cc                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666398\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : kcojkcnw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lesismal \u53d6\u5730\u5740\u8fd9\u91cc\u53ef\u4ee5\u7406\u89e3\u4e3a\u4e00\u4e2a 64 \u4f4d\u673a\u5b50\u7684 machine word \u4e3a 8byte \uff08\u5373 CPU \u80fd\u4fdd\u8bc1\u7684\u539f\u5b50\u64cd\u4f5c\u5927\u5c0f\uff09\uff0c\u521a\u597d\u662f\u4e00\u4e2a pointer \u7684\u5927\u5c0f\uff0c\u6240\u4ee5\u8fd9\u53e5\u662f\u539f\u5b50\u7684\uff0c\u662f\u561b\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666399\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ClarkAbe <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5efa\u8bae\u76f4\u63a5 synv.Map                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666400\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Lpl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lesismal <br \/>@makdon <br \/>\u4f60\u4fe9\u662f\u5728\u4e92\u76f8\u5bf9\u7740\u5938\u5938\u5417\uff1f\u6211\u53ea\u662f\u7ed9\u9898\u4e3b\u4e3e\u51e0\u4e2a\u5176\u5b83\u65b9\u9762\u7684\u601d\u8def<\/p>\n<p>1. atomic \u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u53ea\u662f\u770b\u5230 Incr \u81ea\u7136\u60f3\u5230\u7684\uff0c\u4f60\u4fe9\u4e5f\u8bf4\u4e86\uff0c\u8981\u4e8b\u5148\u77e5\u9053\u6709\u54ea\u4e9b key\uff0c\u628a\u5bf9\u5e94\u7684\u5bf9\u8c61\u521b\u5efa\u51fa\u6765\u3002<br \/>\u90a3\u5bf9\u4e8e web \u5e94\u7528\u6765\u8bf4\uff0chttp_path \u90fd\u662f\u56fa\u5b9a\u7684\u5427\uff1f\u8fd9\u662f\u53ef\u4ee5\u4e8b\u5148\u521b\u5efa\u51fa\u6765\u7684\u3002\u5982\u679c\u9898\u4e3b\u8fd9\u91cc\u662f\u968f\u673a\u7684\uff0c\u53ef\u4ee5\u4e0d\u7528\u8003\u8651\u8fd9\u4e00\u9879\u3002<\/p>\n<p>2. \u5bf9\u4e8e\u4f7f\u7528\u7ba1\u9053\u3002\u4f60\u4eec\u5148\u770b\u660e\u767d\u8981\u89e3\u51b3\u7684\u95ee\u9898\u7684\u6839\u56e0\uff1a\u56e0\u4e3a\u591a\u4e2a\u534f\u7a0b\u53bb\u4e3a\u67d0\u4e2a key +1 \u4f1a\u9020\u6210\u591a\u7ebf\u7a0b\u4e0d\u5b89\u5168\u7684\u95ee\u9898\u3002\u90a3\u6211\u53ea\u7528\u4e00\u4e2a\u7ba1\u9053\u4e5f\u53ef\u4ee5\u505a\u554a\uff0c\u6211\u628a\u62ff\u5230\u7684\u6240\u6709\u8bf7\u6c42\u5168\u90e8\u4e22\u7ed9\u7ba1\u9053\uff0c\u7ba1\u9053\u662f\u6709\u5e8f\u7684\uff0c\u6d88\u8d39\u7aef\u6709\u5e8f\u5904\u7406\uff0c\u8fd8\u9700\u8981\u52a0\u9501\u5417\uff1f<\/p>\n<p>\u5f53\u7136\uff0c\u5047\u5982\u6d88\u8d39\u7aef\u6d88\u8d39\u7684\u6162\uff0c\u53ef\u4ee5\u91c7\u7528\u591a\u4e2a\u534f\u7a0b\u6c42\u6a21\u6765\u505a\u3002\u8fd9\u4e2a\u770b\u5b9e\u9645\u60c5\u51b5\u5206\u6790\u3002<\/p>\n<p>\u4f60\u8bf4\u6211\u7167\u672c\u5ba3\u79d1\u8fd9\u70b9\uff0c\u6055\u6211\u4e0d\u6562\u82df\u540c<\/p>\n<p>3. \u4f60\u80af\u5b9a\u6ca1\u7528\u8fc7 1.8 \u4ee5\u524d\u6ca1\u6709 sync.map \u7684\u573a\u666f\uff0c\u6216\u8005 Java \u91cc\u8fb9\u7684 ConcurrentHashMap \u4e0d\u4e86\u89e3\u3002\u4ee5\u524d\u6ca1\u6709\u539f\u751f sync.map \u662f\u600e\u4e48\u505a Concurrent \u7684\uff1f\u5c31\u662f\u5efa\u4e00\u4e2a 32 \u4f4d\u7684\u6876\uff0c\u628a\u9501\u52a0\u5728\u6876\u4e0a\u8fb9\uff0c\u51cf\u5c0f\u9501\u7684\u7c92\u5ea6\u3002\u53ef\u4ee5\u7b80\u5355\u53c2\u8003\u4e0b\u8fd9\u4e2a\uff1a https:\/\/github.com\/orcaman\/concurrent-map<\/p>\n<p>@makdon <br \/>\u201c\u8bfb\u5199 channel \u7684\u65f6\u95f4\u201d \u4e0e \u201c\u6bcf\u4e00\u6b21\u52a0\u9501\u201d\uff0c\u4f60\u53ef\u4ee5\u5199\u4e2a\u7b80\u5355\u7684 Demo \u505a\u4e00\u4e0b benchmark                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666401\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lesismal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @kcojkcnw \u5bf9\u300232 \u4f4d\u4e5f\u4e00\u6837\uff0cpointer \u662f\u5b57\u957f\uff0c\u5e76\u4e14\u8fd9\u79cd\u975e\u7ed3\u6784\u4f53\u6210\u5458\u53d8\u91cf\u662f\u5bf9\u9f50\u7684\uff0c\u9664\u4e86\u8001\u5954\u817e\u8fd8\u662f\u54ea\u4e2a\u7248\u672c\u5e74\u4ee3\u4e4b\u524d\u7684\uff0ci32 \u4e5f\u662f\u539f\u5b50\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666402\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lesismal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Lpl \u6de1\u5b9a\u70b9\uff0c\u6de1\u5b9a\u70b9<br \/>1. \u6bcf\u4e2a\u8def\u7531\u9884\u5148\u5b58\u5230\u8fd9\u4e2a\u7b80\u5355\u7684\u7edf\u8ba1\u91cc\uff0c\u4ee3\u7801\u4f1a\u5f88\u6f02\u4eae\uff1f\u800c\u4e14\u8fd9\u70b9\u8ba1\u6570\u529f\u80fd\u7528 mutex \u6027\u80fd\u4e5f\u4e0d\u662f\u74f6\u9888<br \/>2. \u7167\u672c\u5ba3\u79d1\u8fd9\u4e2a\u8bcd\u4e0d\u662f\u4e3a\u4e86\u8d2c\u4f4e\uff0c\u800c\u662f\u60f3\u544a\u8bc9\u4f60\u4e0d\u8981\u542c\u522b\u4eba\u8bf4\u597d\u5c31\u4ec0\u4e48\u90fd\u7528\u4ec0\u4e48\uff0c\u8981\u61c2\u5f97\u4ece\u5b9e\u9645\u51fa\u53d1<br \/>3. \u5148\u770b\u61c2\u6211\u56de\u590d\u7684\u5185\u5bb9<br \/>\u53e6\u5916\uff0cchan \u548c mutex \u4f60\u53ef\u4ee5\u81ea\u5df1\u5148 benchmark \u8bd5\u8bd5\uff0cchan \u7684\u6e90\u7801\u5728 runtime\/chan.go \u91cc\uff0c\u672c\u8eab\u5c31\u5e26\u6709\u9501\u7684\u903b\u8f91\uff0c\u5e76\u4e14\u8de8\u8d8a\u4e86\u534f\u7a0b\uff0c\u5982\u679c\u4f60\u89c9\u5f97\u4f1a\u6bd4 mutex \u6027\u80fd\u597d\uff0c\u90a3\u53ef\u4ee5\u8bd5\u8bd5\u770b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666403\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : makdon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Lpl \u662f\u6211\u5355\u65b9\u9762\u5938\u4ed6&#8230;<br \/>1. \u4ece\u4ee3\u7801\u6765\u770b\uff0cid \u662f url path \u91cc\u9762\u53d6\u7684\uff0c\u4e0d\u56fa\u5b9a<br \/>2. \u8c01\u4e3b\u5f20\u8c01\u4e3e\u8bc1\uff0c\u5927\u4f6c benchmark \u6765\u4e00\u4e2a\uff1f\u6211\u7406\u89e3\u53ea\u662f\u4ece\u9501\u6392\u961f\u53d8\u6210\u4e86\u534f\u7a0b\u6392\u961f\u4e86\u800c\u5df2                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666404\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @makdon <br \/>@lesismal <br \/>@GTim <br \/>@Orlion <br \/>@sxfscool <br \/>@Lpl <br \/>@ClarkAbe <br \/>@kcojkcnw<\/p>\n<p>\u5404\u4f4d\u5927\u4f6c\uff0c\u6211\u53c8\u6d4b\u8bd5\u4e86\u4e00\u4e0b\uff0c\u7528 counter = &amp;Counter{data: make(map[string]int)} \u521d\u59cb\u5316\u5168\u5c40\u53d8\u91cf\uff0c\u7136\u540e\u540e\u9762\u91cd\u65b0\u8d4b\u503c\u7684\u65f6\u5019\u4e5f\u52a0\u4e86\u9501\uff0c\u4f46\u662f\u4ecd\u7136\u4e0d\u884c\uff0c\u6253\u5370 accessLog.data \u7684\u65f6\u5019\u7528 &#8220;%s, %x&#8221; \u6253\u5370 key\uff0c\u7ed3\u679c hash \u662f\u4e00\u6837\u7684<\/p>\n<p>https:\/\/p26-tt.byteimg.com\/origin\/pgc-image\/4963875f190e4ccf9b8a89fcbad8590e<br \/>https:\/\/wkphoto.cdn.bcebos.com\/d1160924ab18972b923ebfb4f6cd7b899e510a43.jpg                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666405\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lesismal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @zkdfbb \u6700\u597d\u53ef\u4ee5\u7ed9\u4e00\u4efd\u53ef\u4ee5\u590d\u73b0\u7684\u4ee3\u7801+\u6d4b\u8bd5\u7528\u4f8b\uff0c\u5927\u5bb6\u53ef\u4ee5\u590d\u73b0\u4e0b\u770b\u770b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666406\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u7528\u4e0b\u9762\u7684\u65b9\u5f0f\u6d4b\u8bd5\u4e86\u4e00\u4e0b\uff0c\u6bd4\u4e4b\u524d\u7684\u7ed3\u679c\u8981\u597d\u4e00\u70b9\uff0c\u4f46\u662f\u8fd8\u662f\u4e0d\u5bf9\uff0c\u4f46\u662f tmp \u91cc\u9762\u7684\u8bbf\u95ee\u6b21\u6570\u52a0\u8d77\u6765\u53ea\u6709 nginx \u7684 access.log \u91cc\u9762\u7684\u4e00\u534a<\/p>\n<p> accessLog.Lock()<br \/> tmp := make(map[string]int)<br \/> for k, v := range accessLog.data {<br \/> tmp[k] += v<br \/> }<br \/> accessLog.data = make(map[string]int)<br \/> accessLog.Unlock()                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666407\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : touchwithe <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             golang \u840c\u65b0\u770b\u4e0a\u7684\u5927\u4f6c\u90fd\u597d\u5389\u5bb3\u3002\u5f88\u4e45\u6ca1\u6709\u611f\u53d7\u5230\u8fd9\u79cd\u8ba8\u8bba\u95ee\u9898\u7684\u6c1b\u56f4\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666408\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : no1xsyzy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u59a8\u6253\u5370\u4e0b string(data)\uff0c\u5982\u679c\u662f x00 \u7684\u95ee\u9898\uff0cjson \u91cc\u4f1a\u88ab\u663e\u5f0f\u5730\u8868\u8fbe\u4e3a &#8216;\\&#8217; &#8216;x&#8217; &#8216;0&#8217; &#8216;0&#8217; \u56db\u4e2a\u5b57\u7b26                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666409\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : no1xsyzy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Lpl 1. \u4e00\u6765\u79fb\u690d\u6027\u6709\u95ee\u9898\uff0c\u4e8c\u6765\u5176\u5b9e\u4f60\u5e76\u4e0d\u80fd\u786e\u5b9a http_path \u56fa\u5b9a\uff0c\u53ef\u80fd\u53ea\u662f\u9898\u4e3b\u7684\u6d4b\u8bd5\u4e2d\u56fa\u5b9a\u4e86\u3002<\/p>\n<p>2. chan \u5e95\u5c42\u662f\u9501\u5b9e\u73b0\uff08\u771f\u9501\uff0c\u4e0d\u662f CAS \uff09\uff0c\u6709\u65f6 chan \u6bd4 Mutex \u6548\u7387\u4f4e\u4e00\u4e2a\u6570\u91cf\u7ea7\uff0c\u751a\u81f3\u4e0d\u5982\u4f60\u81ea\u5df1\u5b9e\u73b0\u4e00\u4e2a chan<br \/>\u636e\u8bf4\u6807\u51c6\u5e93\u7684 benchmark \u4f60\u90fd\u627e\u4e0d\u5230\u51e0\u4e2a chan<br \/>\u591a\u6d88\u8d39\u8005\u6765\u5904\u7406\u786e\u5b9e\u6bd4\u5355\u6d88\u8d39\u8005\u5feb\u5f97\u591a\uff08\u56e0\u4e3a\u662f\u6d41\u6c34\u7ebf\uff0c\u4e00\u4e2a\u53bb\u8bfb chan \u4e86\u53e6\u4e00\u4e2a\u5728\u5199 map \uff09\uff0c\u4f46\u603b\u4f53\u800c\u8a00\uff0c\u6700\u540e\u4ecd\u7136\u4e0d\u5982 Mutex\uff0c\u4f55\u51b5\u74f6\u9888\u5728 map\uff0c\u800c\u4e14\u8fd8\u589e\u52a0 gc \u5f00\u9500<br \/>\u8fd9\u7bc7\u6587\u7ae0\u91cc\u6709\u4e00\u4e2a\u8001\u7684 benchmark\uff1a &lt;Mhttps:\/\/bravenewgeek.com\/go-is-unapologetically-flawed-heres-why-we-use-it\/&gt;<\/p>\n<p>3. \u51cf\u5c0f\u9501\u7c92\u5ea6\u81f3\u5c11\u4e0d\u4f1a\u4f7f\u6027\u80fd\u66f4\u7cdf\uff0c\u4f46\u8fd9\u91cc\u663e\u7136\u662f\u8fc7\u65e9\u4f18\u5316\u4e86\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666410\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Lpl <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @makdon <br \/>@lesismal <br \/>\u5199\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u6d4b\u4e86\u4e0b\uff0c\u6027\u80fd\u786e\u5b9e\u5dee Mutex \u633a\u591a\u3002\u662f\u6211\u6ee5\u7528\u4e86<br \/>package counter<\/p>\n<p>type ChanCounter struct {<br \/> data map[string]int<br \/> resultChan chan *string<\/p>\n<p> stopChan &lt;-chan struct{}<br \/>}<\/p>\n<p>func NewChanCounter(stopChan &lt;-chan struct{}) *ChanCounter {<br \/> c := &amp;ChanCounter{<br \/> stopChan: stopChan,<br \/> resultChan: make(chan *string, 10000),<br \/> data: make(map[string]int),<br \/> }<br \/> go c.run()<br \/> return c<br \/>}<\/p>\n<p>func (c *ChanCounter) Incr(key *string) {<br \/> c.resultChan &lt;- key<br \/>}<\/p>\n<p>func (c *ChanCounter) run() {<br \/> for {<br \/> select {<br \/> case r := &lt;-c.resultChan: {<br \/> c.data[*r]++<br \/> }<br \/> case &lt;-c.stopChan:<br \/> break<br \/> }<br \/> }<br \/>}                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666411\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @makdon<br \/>@lesismal<br \/>@GTim<br \/>@Orlion<br \/>@sxfscool<br \/>@Lpl<br \/>@ClarkAbe<br \/>@kcojkcnw <\/p>\n<p>\u6211\u8865\u4e86\u4e00\u4efd\u6700\u5c0f\u6d4b\u8bd5\u7528\u4f8b\uff0c\u4f60\u4eec\u770b\u770b\u80fd\u4e0d\u80fd\u590d\u73b0\uff0c\u6211\u4ecd\u7136\u662f\u4e00\u5934\u96fe\u6c34                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666412\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u662f test.lua \u662f<\/p>\n<p>request = function()<br \/>num = math.random(1, 1)<br \/> path = &#8220;\/item\/id&#8221; .. num<br \/> return wrk.format(&#8220;GET&#8221;, path)<br \/>end<\/p>\n<p>\u5c31\u662f\u94fe\u63a5\u552f\u4e00\u7684\u8bdd\uff0c\u53c8\u6b63\u5e38                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666413\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dallaslu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5f88\u6709\u610f\u601d\u7684\u73b0\u8c61\u3002\u6211\u8dd1\u4e86\u4e00\u4e0b\uff0c\u6253\u5370\u4e86 Incr \u7684\u8fd4\u56de\u503c\u548c accessLog.data:<\/p>\n<p>&#8220;`<br \/>access log: 34reafas0fasdfre7 = 1<br \/>access log: 34reafas0fasdfre8 = 1<br \/>access log: 34reafas0fasdfre8 = 2<br \/>access log: 34reafas0fasdfre8 = 1<br \/>access log: 34reafas0fasdfre8 = 1<br \/>access log: 34reafas0fasdfre8 = 1<br \/>access log: 34reafas0fasdfre8 = 1<br \/>map[34reafas0fasdfre8:1 34reafas0fasdfre8:6]<br \/>&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666414\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dallaslu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @dallaslu <\/p>\n<p>1. \u53ea\u6709\u4e00\u4e2a id \u7684\u8bdd\u6ca1\u6709\u95ee\u9898<br \/>2. \u4e0e Nginx \u65e0\u5173<br \/>3. \u7ecf\u8fc7\u591a\u6b21\u6d4b\u8bd5\uff0c\u603b\u8ba1\u6570\u662f\u6b63\u786e\u7684\uff0c\u53ea\u662f\u4e2a\u522b key \u6253\u5370\u65f6\u663e\u793a\u4e3a\u5176\u4ed6 key<br \/>3. Incr \u8fd4\u56de\u503c\u770b\u8d77\u6765\u9047\u5230\u4e86\u5e76\u53d1\u95ee\u9898\u7684 key\uff0c\u4e00\u822c\u4e5f\u8986\u76d6\u4e86\u5176\u4ed6 key                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666415\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @dallaslu \u786e\u5b9e\u662f\u8fd9\u6837                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666416\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : makdon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             app := fiber.New(fiber.Config{Prefork: false, Immutable: true})<br \/>\u8fd9\u6837\u5199\u5c31\u6b63\u5e38\u4e86<br \/>\u521d\u7565\u770b\u4e86\u4e0b\u4ee3\u7801\uff0c\u4e0d\u4f7f\u7528 immutable \u65f6\uff0c\u6846\u67b6\u662f\u76f4\u63a5\u7528 unsafe \u628a []byte \u8f6c\u6210 string \u7136\u540e\u629b\u51fa<br \/>\u611f\u89c9\u8ddf\u5185\u5b58\u5757\u590d\u7528 \/golang memory model \u6709\u5173<br \/>\u5177\u4f53\u8fd8\u5f97\u4ed4\u7ec6\u770b\u770b\u6e90\u7801                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666417\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dallaslu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u521a\u53c8\u5fcd\u4e0d\u4f4f\u6539\u4ee3\u7801\u5b9e\u9a8c\u4e86\u4e00\u4e0b\uff0c\u4f30\u8ba1\u53ef\u4ee5\u7ed3\u5e16\u4e86\u3002\u5f85\u4e3b\u9a8c\u8bc1\u3002<\/p>\n<p>\u4e3b\u7684\u95ee\u9898\u548c\u5e76\u53d1\u5440\u3001\u9501\u5440\u4e4b\u7c7b\u7684\u53ef\u80fd\u6ca1\u6709\u5173\u7cfb\uff0c\u548c fiber \u5012\u662f\u6709\u5173\u7cfb\u3002<\/p>\n<p>map \u80af\u5b9a\u4e0d\u4f1a\u51fa\u73b0\u91cd\u590d key \u7684\u3002\u6240\u4ee5\u5f53\u6253\u5370 map \u65f6\uff0c\u5982\u679c\u663e\u793a\u6709\u76f8\u540c\u7684 key\uff0c\u90a3\u4e48\u8fd9\u4e2a key \u4e00\u5b9a\u662f\u88ab\u9b3c\u9644\u4e86\u8eab\u3002<\/p>\n<p>\u6b63\u5982 @makdon #45 \u6240\u8bf4\uff0c\u300c id \u662f url path \u91cc\u9762\u53d6\u7684\u300d\uff0c\u90a3\u4e48\u9b3c\u5c31\u662f\u4ece fiber \u6765\u7684\uff0c\u53ef\u80fd\u662f fiber \u91cd\u590d\u4f7f\u7528\u4e86\u5185\u5b58\u7a7a\u95f4\u3002\u6240\u4ee5\u6211\u6539\u4e86\u4e00\u4e0b\uff1a<\/p>\n<p>&#8220;`<br \/>accessLog.Incr(id + &#8220;&#8221;)<br \/>&#8220;`<\/p>\n<p>\u7136\u540e\u95ee\u9898\u5c31\u518d\u6ca1\u590d\u73b0\u8fc7\u4e86\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666418\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dallaslu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @makdon \u542c\u4e0a\u53bb\u9760\u8c31 \ud83d\ude42                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666419\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dallaslu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @makdon #58 \u6b63\u89e3\uff0c\u6211\u8fd9\u91cc\u6d4b\u8bd5\u901a\u8fc7\u3002Immutable \u7684\u6ce8\u91ca\uff1a \u2026so that these values are available even if you return from handler.                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666420\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : no1xsyzy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u628a fiber \u9664\u6389\uff0cgo 2 \u4e2a\u534f\u7a0b\u6216 20 \u4e2a\u534f\u7a0b\u6301\u7eed accessLog.Incr \uff08\u5206\u522b\u4ee5 id1 \u548c id2 \uff09\uff0c\u4e5f\u662f\u5b8c\u5168\u6b63\u5e38\u7684\u6ca1\u6709\u91cd\u590d\u952e\u3002<br \/>\u66f4\u7cbe\u7ec6\u5730\uff0crange accessLog.data \u6765\u6253\u5370\uff0c\u968f\u624b\u5199\u4e86\u5bf9\u6bd4\u76f8\u90bb\u884c key\uff0c\u5f53\u663e\u793a\u76f8\u7b49\u65f6 last_key == key \u5f97 true<br \/>json.Marshal \u7684\u7ed3\u679c\u6240\u6709\u7684\u503c\u90fd\u662f\u540c\u4e00\u4e2a\u503c\uff0c\u663e\u7136\u76f8\u4e92\u8986\u76d6\u4e86\u3002<\/p>\n<p>\u6211\u6682\u65f6\u6401\u7f6e\u4e86\uff0c\u653e\u4e00\u4e9b\u601d\u8def\uff1a<br \/>\u8bd5\u4e0b gin \uff1f<\/p>\n<p>\u8fd9\u6700\u540e\u53ef\u80fd\u8981\u6d89\u53ca\u5230 map \u7684\u5b9e\u73b0\u95ee\u9898\u3002op \u5148\u628a\u76ee\u524d\u7684\u7ed3\u679c\u653e StackOverflow \u5427\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666421\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : makdon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u539f\u56e0\u5e94\u8be5\u662f\u8fd9\u6837\u7684\uff0c\u6ca1\u6709\u5f88\u6df1\u5165\u770b map \u7684\u6e90\u7801(src\/runtime\/map.go)\uff0c\u6240\u4ee5\u5e26\u6709\u731c\u6d4b\u6210\u5206<br \/>\u9996\u5148\u6211\u4eec\u5f80 map \u63d2\u5165\u4e00\u4e2a key \u4e3a id1 \u7684<br \/>\u7136\u540e\u5b8c\u6210\u8bf7\u6c42\u540e\uff0c\u521a\u521a key \u6240\u5360\u7528\u7684 []byte \u88ab\u91cd\u590d\u5229\u7528\uff0ckey \u53d8\u6210\u4e86 id2<br \/>\u731c\u6d4b map \u7684\u5b9e\u73b0\u91cc\u9762\u6ca1\u6709\u62f7\u8d1d\u4e00\u6b21 string\uff0c\u6240\u4ee5 map \u91cc\u9762\u7684 key \u53d8\u6210\u4e86 id2\uff0c\u4f46\u662f hash \u8fd8\u662f\u4e4b\u524d id1 \u7684 hash<br \/>\u7136\u540e\u5206\u4e24\u79cd\u60c5\u51b5:<br \/>&#8211; \u65b0\u63d2\u5165 id1\uff0c!t.key.equal(key, k), \u6240\u4ee5\u7ed9\u5b83\u5206\u914d\u4e86\u4e00\u4e2a\u65b0\u7684\u6876<br \/>&#8211; \u65b0\u63d2\u5165 id2\uff0c\u539f\u6709\u7684 id2 \u8ddf\u65b0\u7684 id2 hash \u4e0d\u76f8\u7b49\uff0c\u4e0d\u4f1a\u8986\u76d6\uff0c\u8fd8\u662f\u7ed9\u5b83\u65b0\u5206\u914d\u4e00\u4e2a\u65b0\u7684\u6876<\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e2a\u5c0f demo\uff0c\u590d\u73b0\u8fd9\u4e2a case\uff0c\u83b7\u5f97\u4e00\u4e2a 200 \u4e2a key\uff0c\u6bcf\u4e2a key \u90fd\u662f id1 \u7684 map<br \/>func main(){<br \/> m := make(map[string]int)<br \/> for i := 0; i &lt; 200; i++{<br \/> b := []byte(&#8220;id2&#8221;)<br \/> str := *(*string)(unsafe.Pointer(&amp;b))<br \/> m[str]++<br \/> b[2] = &#8216;1&#8217;<br \/> }<br \/> fmt.Println(m)<br \/> fmt.Println(len(m))<br \/>}                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666422\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @dallaslu <br \/>@no1xsyzy <br \/>@makdon <\/p>\n<p>\u611f\u8c22\u5206\u6790~ \u7528 Immutable: true \u5c31\u6b63\u5e38\u4e86\uff0c\u53ef\u7ed3\u8d34\u4e86                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666423\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : GTim <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bf4\u6765\u4f60\u4eec\u53ef\u80fd\u4e0d\u76f8\u4fe1\uff0c\u8fd9\u662f `fiber` \u5bfc\u81f4\u7684\u95ee\u9898\uff0c\u54ce\uff0c\u4ee5\u540e\u6709\u673a\u4f1a\u6df1\u7a76<\/p>\n<p>&#8220;`go<br \/>package main<\/p>\n<p>import (<br \/> &#8220;fmt&#8221;<br \/> &#8220;github.com\/gin-gonic\/gin&#8221;<br \/> &#8220;net\/http&#8221;<br \/> &#8220;sync&#8221;<br \/>)<\/p>\n<p>type Counter struct {<br \/> sync.RWMutex<br \/> data map[string]int<br \/>}<\/p>\n<p>func (c *Counter) Incr(key string) int {<br \/> c.Lock()<br \/> c.data[key]++<br \/> count := c.data[key]<br \/> fmt.Println(c.data)<br \/> c.Unlock()<br \/> return count<br \/>}<\/p>\n<p>var (<br \/> accessLog = &amp;Counter{data: make(map[string]int)}<br \/>)<\/p>\n<p>func handler(c *gin.Context) {<br \/> id := c.Param(&#8220;id&#8221;)<br \/> accessLog.Incr(id)<br \/> c.String( http.StatusOK, &#8220;&#8221;)<br \/>}<\/p>\n<p>func main() {<br \/> router := gin.Default()<br \/> router.GET(&#8220;\/item\/:id&#8221;, handler)<br \/> router.Run(&#8220;:8099&#8221;)<br \/>}<\/p>\n<p>&#8220;`<\/p>\n<p>\u7528\u539f\u751f\u7684 `net\/http` \u6216\u8005 `gin` \u5c31\u4e0d\u4f1a\u51fa\u9519                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666424\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lesismal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @GTim \u4e0d\u7528\u4ee5\u540e\u6df1\u5165\u7814\u7a76\uff0c\u5c31\u4eca\u5929\u5427<\/p>\n<p>\u4e0d\u80fd\u602a fiber\uff0cfiber \u662f\u57fa\u4e8e fasthttp \u7684\uff0c\u4ee5\u524d\u770b\u8fc7 fasthttp \u76f8\u5173\u4ecb\u7ecd\u5927\u6982\u610f\u601d\u662f fasthttp \u4e3a\u4e86\u6027\u80fd\uff0c\u5f88\u591a\u5730\u65b9 pool \u590d\u7528\u5185\u5b58\uff0c\u867d\u7136\u6211\u6ca1\u6709\u8bfb fasthttp \u6e90\u7801\uff0c\u53ea\u662f\u5927\u6982\u5206\u6790\uff0c\u4f46\u662f\u5927\u81f4\u539f\u56e0\u5e94\u8be5\u662f\u5dee\u4e0d\u591a\u7684\uff1a<\/p>\n<p>\u5e94\u7528\u5c42\u83b7\u53d6 http \u5404\u79cd\u53c2\u6570\u65f6\u662f\u590d\u7528\u7684[]byte unsafe \u7684\u65b9\u5f0f\u5f3a\u8f6c\u6210 string\uff0c\u7c7b\u4f3c c\/c++\u7684\u6d45\u62f7\u8d1d\uff0c\u65b0\u7684 string \u548c\u539f\u6765\u7684[]byte \u7c7b\u578b\u7ed3\u6784\u4f53\u7684\u6570\u636e\u6307\u9488\u6307\u5411\u540c\u4e00\u6bb5\u5185\u5b58\uff0c\u800c\u5728\u672c\u6b21 handler \u8c03\u7528\u7ed3\u675f\u540e\uff0c\u8fd9\u6bb5[]byte \u5c31\u88ab\u653e\u56de\u4e86 pool \u5e76\u4e14\u4ee5\u540e\u6709\u65b0\u7684\u5730\u65b9\u4f7f\u7528\u65f6\u53c8\u88ab\u62ff\u51fa\u6765<br \/>\u6bd4\u5982\u4e3b\u7684 key \u52a0\u5165\u5230 map \u65f6\u5b57\u9762\u503c\u662f &#8220;a&#8221;\uff0c\u6309\u7167 &#8220;a&#8221; \u7684 hash index \u5b58\u5230\u5bf9\u5e94\u7684 map \u7684 bucket \u91cc\uff0c\u800c\u8fd9\u4e2a string &#8220;a&#8221; \u7684\u7ed3\u6784\u4f53\u5185\u90e8\u6307\u5411\u7684\u5185\u5b58\u88ab\u653e\u56de pool\uff0c\u5176\u4ed6\u5730\u65b9\u518d\u6b21\u4ece pool get \u5230\u65f6\u5c31\u53ef\u80fd\u88ab\u590d\u7528\u7684\u5730\u65b9\u4fee\u6539\uff0c\u6bd4\u5982\u521a\u597d\u5176\u4ed6\u8bf7\u6c42\u7684\u8fd9\u4e2a key \u590d\u7528\u4e86 &#8220;a&#8221; \u7684\u540c\u4e00\u6bb5\u5185\u5b58\u4f46\u662f\u8fd9\u4e9b\u8bf7\u6c42\u7684 key \u4e3a&#8221;b&#8221;\uff0c&#8221;b&#8221; \u52a0\u5230 map \u91cc\u7684\u65f6\u5019\u662f\u6309\u7167 &#8220;b&#8221; \u7684 hash index \u5b58\u5230\u5bf9\u5e94\u7684 bucket \u91cc\u7684\u3001\u4e0d\u540c\u7684 hash index \u5219\u4e0d\u78b0\u649e\u3001\u4e0d\u4f1a\u8ddf\u539f\u6765\u7684\u90a3\u4e2a string &#8220;a&#8221;\uff08\u5f53\u524d\u5b57\u9762\u503c\u4e5f\u662f&#8221;b&#8221;\uff09\u6bd4\u8f83\uff0c\u6240\u4ee5\u5c31\u4ea7\u751f\u4e86\u591a\u4e2a key<\/p>\n<p>\u5b9e\u5728\u4e0d\u559c\u6b22 fasthttp<br \/>\u4f46\u662f fiber \u7684\u63a5\u53e3 \/API \u8bbe\u8ba1\u770b\u7740\u6bd4 gin \u8212\u670d\uff0c\u8fd8\u662f\u633a\u559c\u6b22\u7684<br \/>\u4f46\u662f\u751f\u4ea7\u9879\u76ee\uff0c\u6211\u8fd8\u662f\u4e0d\u6253\u7b97\u7528 fasthttp \u7cfb\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666425\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lesismal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Lpl \u6069\u6069\uff0c\u8fd9\u79cd\u7b80\u5355\u529f\u80fd\u90fd\u4e0d\u4f1a\u6027\u80fd\u74f6\u9888\uff0c\u4e3b\u8981\u8fd8\u8981\u8003\u8651\u8bbe\u8ba1\u4e0a\u7684\u590d\u6742\u5ea6\uff0cchan \u4e0d\u662f\u4e07\u80fd\u7075\u836f\uff0c\u6bd5\u7adf\u52a0\u4e86\u4e00\u5c42 chan\uff0c\u540c\u6b65\u903b\u8f91\u53d8\u6210\u4e86\u5f02\u6b65\u903b\u8f91\uff0c\u6362\u6210 chan \u7684\u5b9e\u73b0\u4e5f\u4e0d\u6bd4 mutex \u6765\u5f97\u7b80\u6d01\uff0c\u5e76\u4e14\u4e5f\u4e0d\u5982\u7528 mutex \u5bb9\u6613\u7406\u89e3<\/p>\n<p>\u9501\u662f\u5f88\u57fa\u7840\u7684\u8bbe\u65bd\uff0c\u4e0d\u8981\u6015\u7528\u5b83                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666426\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lesismal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @makdon <br \/>\u539f\u6765 63 \u5df2\u7ecf\u56de\u590d\u8fc7\u4e86\uff0c66 \u591a\u4f59\u4e86\uff0c\u7f18\u5206                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666427\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lesismal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @makdon 63 \u56de\u7b54\u7684\u597d<br \/>@Lpl \u73b0\u5728\u662f\u4e92\u5938\u4e86<\/p>\n<p>enjoy coding, have fun ~                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666428\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lesismal \u6211\u4e5f\u662f\u770b fiber \u63a5\u53e3\u8bbe\u8ba1\u6bd4\u8f83\u8212\u670d\uff0c\u57fa\u672c\u7684\u529f\u80fd\u4e5f\u90fd\u6bd4\u8f83\u5b8c\u5907\uff0c\u7136\u540e\u597d\u50cf\u8fd8\u8bf4\u4f5c\u8005\u5168\u804c\u5728\u505a\u8fd9\u4e2a\u6240\u4ee5\u7528\u7684\uff0c\u4e4b\u524d\u5c31\u770b\u5230\u8fc7\u4e00\u7bc7\u6587\u7ae0\u8bf4\u9ad8\u5e76\u53d1\u4e0b\u6709\u95ee\u9898\u4e0d\u8fc7\u4e5f\u6ca1\u592a\u5728\u610f\u3002\u3002\u3002\u751f\u4ea7\u73af\u5883\u4e0b\u6709\u5565\u597d\u63a8\u8350\u7684\u4e48<\/p>\n<p>https:\/\/cloud.tencent.com\/developer\/news\/462918                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666429\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lesismal <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @zkdfbb \u57fa\u4e8e\u6807\u51c6\u5e93\u7684\u77e5\u540d\u6846\u67b6\u90fd\u6bd4\u8f83\u7a33\uff0c\u529f\u80fd\u548c\u5468\u8fb9\u4e5f\u90fd\u5dee\u4e0d\u591a\uff0c\u6309 star \u5c31 gin\uff0c\u6309\u559c\u597d\u5c31\u770b\u81ea\u5df1\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666430\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : qieqie <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             9 \u4e00\u6761\u6ca1\u8bf4\u5bf9\u662f\u771f\u7684<br \/>\u53e6\u5916\u8bf4\u4e00\u4e2a\u53cd\u76f4\u89c9\u4f46\u662f\u80fd\u63d0\u5347 map[string]int ++\u8fd9\u6837\u64cd\u4f5c\u7684 trick\uff0c\u5c31\u662f\u6362\u6210 map[string]*int<br \/>\u53c2\u8003\uff1a https:\/\/github.com\/golang\/go\/issues\/45021                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666431\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zkdfbb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @qieqie \u8fd9\u6837\u786e\u5b9e\u4f1a\u66f4\u5feb\u4e00\u70b9\uff0c\u4e0d\u8fc7\u5e94\u8be5\u57fa\u672c\u65e0\u5f71\u54cd\u3002\u5c31\u50cf\u5f88\u591a\u6846\u67b6\u7684 benchmark \u5dee\u5f88\u591a\uff0c\u4f46\u662f\u67b6\u4e0d\u4f4f\u52a0\u4e0a\u81ea\u5df1\u7684\u4e1a\u52a1\u903b\u8f91\u540e\u90fd\u5dee\u4e0d\u591a\u4e86\u3002\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666432\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fenglangjuxu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Lpl #52 \u7406\u8bba\u5c0f\u767d \u8bda\u5fc3\u6c42\u6559 \u65e0\u610f\u5192\u72af <\/p>\n<p>&#8220;`<br \/>case r := &lt;-c.resultChan:<br \/> {<br \/>\/\/ ???\u8fd9\u91cc\u4e0d\u7528\u52a0\u9501\u4e48???<br \/> c.data[*r]++<br \/> }<br \/>&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666433\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : makdon <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @fenglangjuxu \u4ed6\u7528 chan \u6392\u961f\u4e86\uff0c\u4e00\u4e2a\u534f\u7a0b\u4e13\u95e8\u5904\u7406 data\uff0c\u5176\u5b83\u534f\u7a0b\u8bbf\u95ee\u4e0d\u5230                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5666434\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fenglangjuxu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @makdon #75 \u5965 \u591a\u8c22\u89e3\u7b54                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>map \u7684\u4e00\u4e2a\u795e\u5947\u7684\u95ee\u9898 \u8cc7\u6df1\u5927\u4f6c&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/428298"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=428298"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/428298\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=428298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=428298"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=428298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}