在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:只是测试兴趣,相信大家很多人都知道怎么解决,自己只是做个笔记,原则上还是希望公司支持正版