在github上下載了ServiceStack.Redis,做測試發現有限制,居然從v4開始就收費,無聊時,做了個源碼分析
廢話不多,上測試代碼
try { for (int i = 0; i < 7000; i++) { redisClient = new RedisClient(host, port); redisClient.Set<string>("w", "1"); Console.WriteLine(i); } } catch (Exception ex) { Console.WriteLine(ex.Message); throw; }
運行到6000時會報錯,錯誤信息如下
The free-quota limit on '6000 Redis requests per hour' has been reached. Please see https://servicestack.net to upgrade to a commercial license or visit https://github.com/ServiceStackV3/ServiceStackV3 to revert back to the free ServiceStack v3.
試了下v3,就沒此問題
修改源碼解決此屏蔽方法:
查找LicenseUtils的調用注釋即可,涉及地方如下
1、RedisClient.cs的第379行
2、RedisNativeClient_Utils.cs的第61到71行
3、RedisNativeClient_Utils.cs的第322到323行
ps:只是測試興趣,相信大家很多人都知道怎么解決,自己只是做個筆記,原則上還是希望公司支持正版