Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • eugenekr 10 posts 30 karma points
    Mar 10, 2011 @ 02:20
    eugenekr
    0

    unpublished items stay until web.config touched

    linq2umbraco keeps including unpublished nodes in the list until I touch web.config

    Is there a way to make refresh automatically? 

     Thanks!

  • eugenekr 10 posts 30 karma points
    Mar 14, 2011 @ 00:38
    eugenekr
    0

    Did anyone encounter this issue? I've been searching for third party umbraco package for cache refreshing but couldn't find one.

    At least, how long umbraco linq cache lasts after item being unpublished/deleted?

    I'm saying about linq2umbraco problem because node factorty works correctly (it does not return such nodes)

  • eugenekr 10 posts 30 karma points
    Mar 15, 2011 @ 03:26
    eugenekr
    0

    Thanks everyone for great zen style help!

    Solution is as follows:

    Subscribe to umbraco events, say in Application_Start function in Global.asax

    content.AfterRefreshContent += new content.RefreshContentEventHandler(content_AfterRefreshContent);
    content.AfterUpdateDocumentCache += new content.DocumentCacheEventHandler(content_AfterRefreshContent);
    content.AfterClearDocumentCache += new content.DocumentCacheEventHandler(content_AfterRefreshContent);

    Refresh linq2umbraco cache in event handler:

    void content_AfterRefreshContent(umbraco.cms.businesslogic.web.Document sender, CancelEventArgs e)
            {
                var ctx = ContainerProvider.RequestLifetime.Resolve<IMyDataContext>();
                var dp = ctx.DataProvider as NodeDataProvider;
                if (dp != null)
                    dp.Flush();
            }

     

     

  • Amigo 243 posts 568 karma points
    Mar 15, 2011 @ 21:59
    Amigo
    0

    Hi eugenekr, im trying to do this too, but where comes "ContainerProvider" from?
    Do i need a reference for using it? 

  • eugenekr 10 posts 30 karma points
    Mar 15, 2011 @ 22:39
    eugenekr
    0

    Hi Amigo!

    It is not umbraco specific. ContainerProvider comes from Autofac, dependency injection framework, we use this thing to get reference to data context (that implements IMyDataContext interface). 

     

     

Please Sign in or register to post replies

Write your reply to:

Draft