Example #1
0
        public void CheckCompletedTest()
        {
            var keys = new[] { "testkey1", "testkey2" };
            var vals = new[] { "1", "2" };

            RedisConnectionPool.SetExpire(keys, vals, 300);
            RedisConnectionPool.Process(c =>
            {
                var values = new List <string>();
                using (var p = c.CreatePipeline())
                {
                    foreach (var key in keys)
                    {
                        string k = key;
                        p.QueueCommand(cli => cli.Get <string>(k), v =>
                        {
                            values.Add(v);
                        });
                    }
                    p.Flush();
                }
                Trace.WriteLine(string.Join(",", values));
            });
            var watch = Stopwatch.StartNew();
            var data  = ShareCacheStruct.Get <ChildData>(1);

            data.Age++;
            bool result = CacheFactory.CheckCompleted();

            Trace.WriteLine("Queue result:" + result);
            WaitEnd(watch);
        }
Example #2
0
        public void KeyCharTest()
        {
            var    watch = Stopwatch.StartNew();
            string key   = "Test_1_B|A@#-$~'%";
            var    cache = new ShareCacheStruct <KeyData>();
            var    data  = ShareCacheStruct.Get <KeyData>(key, true);

            if (data == null)
            {
                cache.Add(new KeyData()
                {
                    Key = key, Value = key
                });
                WaitEnd(watch);
                cache.UnLoad();
                data = ShareCacheStruct.Get <KeyData>(key, true);

                Assert.IsNotNull(data, "find key faild");
            }
            int         userId = 1380000;
            UserKeyData userData;
            var         userCache = new PersonalCacheStruct <UserKeyData>();

            if (userCache.TryFindKey(userId.ToString(), out userData, userId, key) == LoadingStatus.Success)
            {
                if (userData == null)
                {
                    userCache.Add(new UserKeyData()
                    {
                        UserId = userId, Key = key, Value = key
                    });
                    WaitEnd(watch);
                    userCache.UnLoad();
                    userData = userCache.FindKey(userId.ToString(), userId, key);
                    Assert.IsNotNull(userData, "find key faild");
                }
            }
        }