Aggressive cache not used for lazily loaded documents with disabled changes tracking

60 views
Skip to first unread message

Andrej Krivulčík

unread,
Nov 23, 2020, 3:59:49 AM11/23/20
to RavenDB - 2nd generation document database
When loading documents lazily with changes tracking disabled, the aggressive cache is not used. Failing test (tested on 5.1.0, tests are almost identical to the ones in https://groups.google.com/g/ravendb/c/700pC-kkZk4, except for AggressiveCacheMode.DoNotTrackChanges (and fixed typos)):

using Raven.TestDriver;
using System;
using System.Threading.Tasks;
using Raven.Client.Http;
using Xunit;

namespace RavenDB5Tests.Tests
{
    public class AggressiveCacheWithLazyWithoutChangesTracking : RavenTestDriver
    {
        [Fact]
        public async Task AggressiveCacheWithLazyTestAsync()
        {
            using var store = GetDocumentStore();

            var requestExecutor = store.GetRequestExecutor();
            using (var session = store.OpenSession())
            {
                session.Store(new Doc { Id = "doc-1" });
                session.SaveChanges();
            }

            using (var session = store.OpenAsyncSession())
            using (session.Advanced.DocumentStore.AggressivelyCacheFor(TimeSpan.FromMinutes(5), AggressiveCacheMode.DoNotTrackChanges))
            {
                var docLazy = session.Advanced.Lazily.LoadAsync<Doc>("doc-1");
                var doc = await docLazy.Value;
            }

            var requests = requestExecutor.NumberOfServerRequests;

            using (var session = store.OpenAsyncSession())
            using (session.Advanced.DocumentStore.AggressivelyCacheFor(TimeSpan.FromMinutes(5), AggressiveCacheMode.DoNotTrackChanges))
            {
                var cachedDocLazy = session.Advanced.Lazily.LoadAsync<Doc>("doc-1");
                var cachedDoc = await cachedDocLazy.Value;
            }

            Assert.Equal(requests, requestExecutor.NumberOfServerRequests);
        }

        [Fact]
        public void AggressiveCacheWithLazyTest()
        {
            using var store = GetDocumentStore();

            var requestExecutor = store.GetRequestExecutor();
            using (var session = store.OpenSession())
            {
                session.Store(new Doc { Id = "doc-1" });
                session.SaveChanges();
            }

            using (var session = store.OpenSession())
            using (session.Advanced.DocumentStore.AggressivelyCacheFor(TimeSpan.FromMinutes(5), AggressiveCacheMode.DoNotTrackChanges))
            {
                var docLazy = session.Advanced.Lazily.Load<Doc>("doc-1");
                var doc = docLazy.Value;
            }

            var requests = requestExecutor.NumberOfServerRequests;

            using (var session = store.OpenSession())
            using (session.Advanced.DocumentStore.AggressivelyCacheFor(TimeSpan.FromMinutes(5), AggressiveCacheMode.DoNotTrackChanges))
            {
                var cachedDocLazy = session.Advanced.Lazily.Load<Doc>("doc-1");
                var cachedDoc = cachedDocLazy.Value;
            }

            Assert.Equal(requests, requestExecutor.NumberOfServerRequests);
        }

        public class Doc
        {
            public string Id { get; set; }
        }
    }
}


Grisha Kotler

unread,
Nov 23, 2020, 1:04:53 PM11/23/20
to rav...@googlegroups.com
You can track the status of this issue here:

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ravendb/03a134cc-06da-4f52-a1e3-d3b1efbd85cfn%40googlegroups.com.

Andrej Krivulčík

unread,
Dec 9, 2020, 11:13:22 AM12/9/20
to RavenDB - 2nd generation document database
Any estimate about when this could be looked into?

Egor Shamanaev

unread,
Dec 14, 2020, 5:18:11 AM12/14/20
to rav...@googlegroups.com
Hi

According to the link it is scheduled to current sprint



--
Egor
Developer   /   Hibernating Rhinos LTD
Reply all
Reply to author
Forward
0 new messages