SuperSocket icon indicating copy to clipboard operation
SuperSocket copied to clipboard

請問新版 (.net core) SuperSocket 是否考慮直接使用 Guid 做為 Session Id ?

Open overing opened this issue 5 years ago • 5 comments

目前的 SuperSocket 似乎都是以 Guid ToString 的方式生成 Session Id 是否考慮直接以 Guid 做為 Session Id 或是開放如 <TSessionId> 之類的 Generic Param 來由外部決定? 主要是想優化後方的應用在進行大量的 Session Id 傳遞與儲存的時候 能夠省略 Guid <-> String <-> Guid 的計算與空間成本

https://imgur.com/WG4c1Km

overing avatar Aug 07 '19 00:08 overing

Probably just use the object's hash code?

kerryjiang avatar Aug 07 '19 01:08 kerryjiang

session.GetHashCode() ? 這個點子不錯 不過似乎還是避免不了生成 session 當下的 ToString() 分配 https://github.com/kerryjiang/SuperSocket/blob/master/src/SuperSocket.Server/AppSession.cs#L27

overing avatar Aug 07 '19 02:08 overing

附上 ConcurrentDictionary 對兩種 key 的存取效能測試 https://drive.google.com/open?id=1mhLT1Vm6lnIx7fwsL3iTvYGpFXGG-PFN

overing avatar Aug 07 '19 04:08 overing

What about if the SessionID is a number (long)?

kerryjiang avatar Jan 03 '20 23:01 kerryjiang

我觉得SessionID使用string的设计是比较通用的, 你可以将SessionID替换为你需要的标识种类, 这个ID可以替换为设备ID, 那我大概率就省去了需要自己实现SessionManager的麻烦

wosledon avatar Apr 02 '21 10:04 wosledon