Exemplo n.º 1
0
        public void SecondLevelCacheWithDifferentRegionsFuture()
        {
            using (ISession session = SessionFactory.OpenSession())
            {
                // Query results should be cached
                CacheableUser user = session.DelayedFlowQuery <CacheableUser>()
                                     .Cacheable("region1")
                                     .Where(x => x.Name == "test")
                                     .Select();

                Assert.That(user, Is.Not.Null);

                Delete(session);
            }

            using (ISession session = SessionFactory.OpenSession())
            {
                // Query results should be cached
                CacheableUser user = session.DelayedFlowQuery <CacheableUser>()
                                     .Cacheable("region2")
                                     .Where(x => x.Name == "test")
                                     .Select();

                Assert.That(user, Is.Null, "entity from different region should not be retrieved");
            }
        }
Exemplo n.º 2
0
        public void SecondLevelCacheWithSingleCacheableQueryFuture()
        {
            using (ISession session = SessionFactory.OpenSession())
            {
                // Query results should be cached
                CacheableUser temp = session.FlowQuery <CacheableUser>()
                                     .Cacheable()
                                     .Where(x => x.Name == "test")
                                     .Select();

                Assert.That(temp, Is.Not.Null);

                Delete(session);
            }

            using (ISession session = SessionFactory.OpenSession())
            {
                CacheableUser temp = session.FlowQuery <CacheableUser>()
                                     .Cacheable()
                                     .Where(x => x.Name == "test")
                                     .Select();

                Assert.That(temp, Is.Not.Null, "entity not retrieved from cache");
            }
        }
Exemplo n.º 3
0
        protected override void OnSetup()
        {
            using (ISession session = SessionFactory.OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    var user = new CacheableUser
                    {
                        Name = "test"
                    };

                    session.Save(user);
                    transaction.Commit();
                }
            }
        }