예제 #1
0
        static Current()
        {
            var connection = new AsyncRedisConnection(null, "127.0.0.1:6379,connectTimeout=10", () => false, "", "ryujit-debug");
            var syncRoot = new object();
            var localCache = new LocalCache(syncRoot, 0);
            var redis = new AsyncDelayedRedisCache("connect", new Messaging(connection), connection, localCache, new NullCache(0), 0, "dev");
            SiteCache = new ImmediateCache(redis, 0);

            #pragma warning disable 618
            LocalCache.LogDuration += (string key, string caller, int? duration) =>
            #pragma warning restore 618
            {
                if (key.Contains("guid-test"))
                {
                    switch (caller)
                    {
                        case "LocalCache.Set":
                            CurrentTest.LocalCacheSetDuration = duration;
                            break;
                        case "LocalCache.SetWithPriority":
                            CurrentTest.LocalCacheSetWithPriorityDuration = duration;
                            break;
                        case "RawSet":
                            CurrentTest.RawSetDuration = duration;
                            break;
                    }
                }
            };
        }
        private string GetFormattedInfo()
        {
            var server = AsyncRedisConnection.TryGetServer(subscriber);

            if (server == null)
            {
                return("");
            }
            var all  = server.InfoRaw();
            var data = ParseInfo(all);

            return(string.Join(Environment.NewLine, data.Select(pair => pair.Key + "\t" + pair.Value)));
        }
        string IRedisLite.GetInfo(bool allowTalkToServer)
        {
            var server = AsyncRedisConnection.TryGetServer(subscriber, false);

            if (server == null)
            {
                return("");
            }
            return("AsyncRedis; " + EndPointCollection.ToString(server.EndPoint) + Environment.NewLine
                   + "Server version: " + server.Version + Environment.NewLine + Environment.NewLine
                   + server.Features + Environment.NewLine
                   + server.GetCounters().ToString() + Environment.NewLine + Environment.NewLine
                   + (allowTalkToServer ? (GetFormattedInfo() + Environment.NewLine + Environment.NewLine) : "")
                   + StackRedis.AsyncDelayedRedisCache.GetExpensiveQueries());
        }