What is difference between UpdateDocumentCache and RefreshContentFromDatabaseAsync?
More specifically: I've created a Document object, modified it, and now want to reliably save and publish it to the net using Umbraco 4. I was using "umbraco.library.UpdateDocumentCache()" at first, but occasionally, it would seem that the document wasn't being published (could this be a browser cache issue?).
In some example code, I've seen "umbraco.content.Instance.RefreshContentFromDatabaseAsync();" used after publishing. Upon throwing this line after the UpdateDocumentCache() call, things seem to work reliably.
I'd be very grateful if someone could help me to understand the distinction and use of these two methods.
For either to work you need to make sure that the document was published first, otherwise the changes wont get published out into the XML.
The different between the two is what they involve. UpdateDocumentCache is a proper refresh of the disk cache, memory cache and sitemap. I don't believe that the RefreshContentFromDatabaseAsync does the sitemap. Also, as the name indicates, the Async method is done via the ThreadPool, so if may not be immidiately visible.
But really I just got that from looking into the code :P
As @slace says you must publis the document first before calling the UpdateDocumentCache Method. I've updated the wiki on this subject last weekend.You'll find it here
Example code from the Wiki:
//Create new DocumentObject Document doc =newDocument(id); //Mark the document for publish under Admin account doc.Publish(newUser(0)); //Publish the document by Updating umbraco.config file library.UpdateDocumentCache(doc.Id);
Don't know about the umbraco.content.Instance.RefreshContentFromDatabaseAsync(); method but the level 2 training tells you to use the UpdateDocumentCache Method so i consider that as a best practice.
@slace: thank you very much for that explanation. I did poke around the code but due to a certain degree of .NET newbishness, I wasn't able to wrap my mind around it. Armed with your digest, the methods now make much more sense to me. Had I more Karma, I'd definitely give you a thumbs up :)
Richard: thank you for that concrete example. I had been running that same code and so I'm not totally sure why things stopped working for me. I suspect that I didn't actually disable my browser's cache so it's very likely this whole episode of confusion was based on some poor debugging on my part :X. In any event, thank you very much for making this process extremely clear.
Thanks, all -- the Umbraco community is truly remarkable!
What is difference between UpdateDocumentCache and RefreshContentFromDatabaseAsync?
More specifically: I've created a Document object, modified it, and now want to reliably save and publish it to the net using Umbraco 4. I was using "umbraco.library.UpdateDocumentCache()" at first, but occasionally, it would seem that the document wasn't being published (could this be a browser cache issue?).
In some example code, I've seen "umbraco.content.Instance.RefreshContentFromDatabaseAsync();" used after publishing. Upon throwing this line after the UpdateDocumentCache() call, things seem to work reliably.
I'd be very grateful if someone could help me to understand the distinction and use of these two methods.
Thank you!
For either to work you need to make sure that the document was published first, otherwise the changes wont get published out into the XML.
The different between the two is what they involve. UpdateDocumentCache is a proper refresh of the disk cache, memory cache and sitemap. I don't believe that the RefreshContentFromDatabaseAsync does the sitemap. Also, as the name indicates, the Async method is done via the ThreadPool, so if may not be immidiately visible.
But really I just got that from looking into the code :P
Hi,
As @slace says you must publis the document first before calling the UpdateDocumentCache Method. I've updated the wiki on this subject last weekend.You'll find it here
Example code from the Wiki:
Don't know about the umbraco.content.Instance.RefreshContentFromDatabaseAsync(); method but the level 2 training tells you to use the UpdateDocumentCache Method so i consider that as a best practice.
Hope this helps you,
Richard
@slace: thank you very much for that explanation. I did poke around the code but due to a certain degree of .NET newbishness, I wasn't able to wrap my mind around it. Armed with your digest, the methods now make much more sense to me. Had I more Karma, I'd definitely give you a thumbs up :)
Richard: thank you for that concrete example. I had been running that same code and so I'm not totally sure why things stopped working for me. I suspect that I didn't actually disable my browser's cache so it's very likely this whole episode of confusion was based on some poor debugging on my part :X. In any event, thank you very much for making this process extremely clear.
Thanks, all -- the Umbraco community is truly remarkable!
is working on a reply...