You can’t cache DateTime.Now
One of the things that were itching me was the fact that it seems that not all the queries in RaccoonBlog were hitting the cache. Oh, it is more than fast enough, but I couldn’t really figure out what is going on there. Then again, it was never important enough for me to dig in.
I was busy doing the profiling stuff for RavenDB and I used RaccoonBlog as my testing ground, when I realized what the problem was:
Everything was working just fine, the problem was here:
Do you get the light bulb moment that I had? I was using Now in a query, and since Now by definition changes, we keep generating new queries, which can’t be cached, etc.
I changed all of the queries that contained Now to:
Which means that it would only use a different value every minute. Once I fixed that, I still saw that there was a caching problem, which led me to discover that there was an error in how we calculated etags for dynamic indexes after they have been promoted. Even a very basic profiling tool helped us fix two separate bugs (in Raccoon Blog and in RavenDB).
Comments
Do you plan on leaving the profiler running on your blog indefinitely?
João , Highly likely, why?
Seems like a case where Now should have been hidden in a domain abstraction would have meant one place to dó the fix. Not to mention testability
We talked about this at the ravendb maillist. You would not have run into this problem when a Post is "by definition" not deleted and public (own collection). Of course you then need to take care of future posts and how to handle deleted posts, but I see those operations as 'tiny points in time' while quering public posts is something that needs to be 'fast and sound' all the time. ;)
// Ryan
I think that's awesome!
Comment preview