Ejemplo n.º 1
0
        public void Test5()
        {
            ISoodaCache c  = new SoodaInProcessCache();
            string      ck = "Contact where 1=2";

            c.Add("Contact", 1, DummyEntry(1), TimeSpan.FromHours(1), false);
            c.Add("Contact", 2, DummyEntry(2), TimeSpan.FromHours(1), false);
            c.Add("Contact", 3, DummyEntry(3), TimeSpan.FromHours(1), false);
            c.StoreCollection(ck, "Contact", new int[] { 1, 2, 3 }, new string[0], true, TimeSpan.FromHours(1), false);
            Assert.IsNotNull(c.LoadCollection(ck));
            Assert.AreEqual(3, c.LoadCollection(ck).Count);
            c.Evict("Contact", 3);
            Assert.IsNull(c.LoadCollection(ck));
        }
Ejemplo n.º 2
0
        public void Test10()
        {
            using (TestSqlDataSource testDataSource = new TestSqlDataSource("default"))
            {
                testDataSource.Open();

                SoodaInProcessCache myCache = new SoodaInProcessCache();
                using (SoodaTransaction tran = new SoodaTransaction())
                {
                    tran.RegisterDataSource(testDataSource);
                    tran.Cache         = myCache;
                    tran.CachingPolicy = new SoodaCacheAllPolicy();

                    string      ck1 = SoodaCache.GetCollectionKey("Vehicle", new SoodaWhereClause(true));
                    VehicleList c1  = Vehicle.GetList(true);

                    string   ck2 = SoodaCache.GetCollectionKey("Bike", new SoodaWhereClause(true));
                    BikeList c2  = Bike.GetList(true);

                    string   ck3 = SoodaCache.GetCollectionKey("Bike", new SoodaWhereClause(false));
                    BikeList c3  = Bike.GetList(false);

                    Assert.IsNotNull(myCache.LoadCollection(ck1));
                    Assert.IsNotNull(myCache.LoadCollection(ck2));
                    Assert.IsNotNull(myCache.LoadCollection(ck3));

                    myCache.Evict("Vehicle", 1);

                    // ck2 is not evicted because vehicle[1] is not a bike
                    // ck3 is not evicted because it contains zero objects

                    Assert.IsNull(myCache.LoadCollection(ck1));
                    Assert.IsNotNull(myCache.LoadCollection(ck2));
                    Assert.IsNotNull(myCache.LoadCollection(ck3));
                }
            }
        }
Ejemplo n.º 3
0
        public void Test11()
        {
            using (TestSqlDataSource testDataSource = new TestSqlDataSource("default"))
            {
                testDataSource.Open();

                SoodaInProcessCache myCache = new SoodaInProcessCache();
                using (SoodaTransaction tran = new SoodaTransaction())
                {
                    tran.RegisterDataSource(testDataSource);
                    tran.Cache         = myCache;
                    tran.CachingPolicy = new SoodaCacheAllPolicy();

                    string      ck1 = SoodaCache.GetCollectionKey("Vehicle", new SoodaWhereClause(true));
                    VehicleList c1  = Vehicle.GetList(true, SoodaSnapshotOptions.KeysOnly);

                    string   ck2 = SoodaCache.GetCollectionKey("Bike", new SoodaWhereClause(true));
                    BikeList c2  = Bike.GetList(true, SoodaSnapshotOptions.KeysOnly);

                    string   ck3 = SoodaCache.GetCollectionKey("Bike", new SoodaWhereClause(false));
                    BikeList c3  = Bike.GetList(false, SoodaSnapshotOptions.KeysOnly);

                    Assert.IsNotNull(myCache.LoadCollection(ck1));
                    Assert.IsNotNull(myCache.LoadCollection(ck2));
                    Assert.IsNotNull(myCache.LoadCollection(ck3));

                    myCache.Evict("Vehicle", 1);

                    // nothing is evicted from collection cache because we requested KeysOnly

                    Assert.IsNotNull(myCache.LoadCollection(ck1));
                    Assert.IsNotNull(myCache.LoadCollection(ck2));
                    Assert.IsNotNull(myCache.LoadCollection(ck3));
                }
            }
        }