Copied to clipboard

Flag this post as spam?

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


  • Tim C 161 posts 528 karma points
    Jun 06, 2016 @ 10:08
    Tim C
    0

    Using ApplicationContext.Current.ApplicationCache.Runtime

    I would like to store a small number of text strings in the runtime cache

    using Umbraco.Core.CacheHelper
    

    ie

    ApplicationContext.Current.ApplicationCache.Runtime
    

    but after searching, I am not 100% clear on how to get and to set values - can anyone supply an example.

    I think I can use get to also set values but how would I update them once set?

    I have tried

    ApplicationContext.ApplicationCache.RuntimeCache.InsertCacheItem

    where I have created a class myObject and and instance rC but this crashes

    Compiler Error Message: CS0120: An object reference is required for the non-static field, method, or property 'Umbraco.Core.ApplicationContext.ApplicationCache.get'
    
  • Wayne 19 posts 59 karma points
    Sep 29, 2016 @ 06:10
    Wayne
    101

    I believe you need to work with an instance of the cache.

    var cache = ApplicationContext.Current.ApplicationCache.RuntimeCache;
    cache.GetCacheItem("rssFeed")
    cache.InsertCacheItem("rssFeed", ()=> { return nodeList; }, timeout: TimeSpan.FromDays(2));
    
Please Sign in or register to post replies

Write your reply to:

Draft