locked
EntLib 5 backing store performance RRS feed

  • Question

  • I am a beginner on using  Enterprise Library 5.0's Caching Application Block.

    My Goals:

    1, using in-memory cache to record my data,and Sqlserver as persist storage;

    2, when I add data to the cache, but the cache is full filled with the cacheItems, and none of the item is  Expired, the Item that will be delete from the memory should first store into the database .

    3, as i say in the 2,in the CacheManager's GetData method, the application will check the in memory cache first, if not exist ,then check the database ,and return the result.

    My Question:

    1, About the entLib's synchronized backing store , i doubt that whether it will have a better performance, comparing with the way only use the database to record the data. 

    2, if i want to achieve my goal 2 and 3 ,how can pass my own implement of  IBackingStore to the CacheManager ? what's the best practise? 

    thanks


    • Edited by o.myl Friday, July 8, 2016 7:17 AM
    Friday, July 8, 2016 4:05 AM

Answers

  • I suggest you look into another caching technology / framework. The Enterprise Library as a whole hasn't been under active development since 2013 and the caching block is deprecated in Enterprise Library 6.

    Some options are Redis if you are looking for something on a larger scale. I recommend using the StackExchange Redis client.

    If you do not need something that is distributed and larger in scale, then the .NET MemoryCache should suffice.


    william xifaras



    • Proposed as answer by William Xifaras Friday, July 8, 2016 7:39 PM
    • Edited by William Xifaras Friday, July 8, 2016 11:22 PM
    • Marked as answer by o.myl Saturday, July 9, 2016 12:08 PM
    • Unmarked as answer by o.myl Sunday, July 10, 2016 12:31 AM
    • Marked as answer by o.myl Sunday, July 10, 2016 12:31 AM
    Friday, July 8, 2016 7:39 PM

All replies

  • I suggest you look into another caching technology / framework. The Enterprise Library as a whole hasn't been under active development since 2013 and the caching block is deprecated in Enterprise Library 6.

    Some options are Redis if you are looking for something on a larger scale. I recommend using the StackExchange Redis client.

    If you do not need something that is distributed and larger in scale, then the .NET MemoryCache should suffice.


    william xifaras



    • Proposed as answer by William Xifaras Friday, July 8, 2016 7:39 PM
    • Edited by William Xifaras Friday, July 8, 2016 11:22 PM
    • Marked as answer by o.myl Saturday, July 9, 2016 12:08 PM
    • Unmarked as answer by o.myl Sunday, July 10, 2016 12:31 AM
    • Marked as answer by o.myl Sunday, July 10, 2016 12:31 AM
    Friday, July 8, 2016 7:39 PM
  • Very appreciate for your answer.Now I choose the MemoryCache to do that.



    • Edited by o.myl Saturday, July 9, 2016 12:08 PM
    Saturday, July 9, 2016 12:07 PM
  • Good choice. Look into using the AddOrGetExisting method when using the MemoryCache.

    william xifaras

    Saturday, July 9, 2016 1:59 PM
  • Mmm. I learned the basic usage of MemoryCache. Another question is my project demands mulitple cache. I searched the solution Here and got that the mulitple MemoryCache will loses performance at max load instead of gaining. 

    Can you give me some suggestions about that? should i use single instance of MemoryCache and construct the key like this "{cacheName}-{keyName}" ?

    thank you for your patience.



    • Edited by o.myl Sunday, July 10, 2016 1:10 AM
    Sunday, July 10, 2016 1:01 AM
  • I agree with that answer on stackoverflow.

    The following makes sense:

    "In my case after reading up about this, I switched to using one 'public static MemoryCache' in my app and I simply segregated cached items by their cache keys. For example if you want to cache on a per instance you could have a cache key like something like "instance-{instanceId}-resourceName-{resourceId}". Think of it as name spacing your cache entries."

    You should also consider specifying the maximum amount of physical memory dedicated to the MemoryCache. You can do this in the config.

    https://msdn.microsoft.com/en-us/library/dd941874.aspx


    william xifaras

    Monday, July 11, 2016 2:57 PM