locked
How To Create A Flatform Agnostic Cache RRS feed

  • General discussion

  • Right now my group has a library for web sites that caches data using httpcontext.current.session, httpcontext.current.application, and httpcontext.current.cache.

     My manager now wants to refactor this library so that it will be flatform agnostic, so that it works with some of our desktop apps. Obviosly we can't use httpcontext.

    Are there any solutions out there for this? Patterns, suggestions, practices?


    chuckdawit
    • Edited by witdaj Wednesday, November 23, 2011 10:23 PM
    Wednesday, November 23, 2011 10:23 PM

All replies

  • You might want to look at switching to using MemoryCache.  It was designed for exactly that purpose...

     

     


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Wednesday, November 23, 2011 10:31 PM
  • Hi Reed.

    I think you responded to some of my other posts in another forum about this.

    What I don't understand, and its probably because I'm not that familar with httpcontext, is that when we have different people using our sites and we need to save different sessions, etc, how can MemoryCache tell the difference between each of the different sessions?


    chuckdawit
    Wednesday, November 23, 2011 11:07 PM
  • You can create a MemoryCache instance per  session.  
    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Wednesday, November 23, 2011 11:50 PM
  • So here is where I'm lost.

    If this has to be platform agnostic so I can use it on WPF and console applications there wouldn't be a session. Right?


    chuckdawit
    Wednesday, November 23, 2011 11:56 PM
  • Your API would have to have some hook to create/fetch the current cache, ie:

    Func<MemoryCache> CacheAccessor { get; set; }
    


    It could default to just returning the default MemoryCache, but your ASP implementation could override it to return a session-based cache...

     


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Thursday, November 24, 2011 12:14 AM
  • Do you have any examples of this or know where I could find one?

    When you say in one of your posts, "create a new memorycache instance per session" how would that look?

    What would you do to determine if it was a new session?


    chuckdawit
    • Edited by witdaj Monday, November 28, 2011 5:08 AM
    Monday, November 28, 2011 5:04 AM