Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 774447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:08:02+00:00 2026-05-14T19:08:02+00:00

Since the default implementation of CacheManager doesn’t provide GetItemsOfType<> (and many others) I thought

  • 0

Since the default implementation of CacheManager doesn’t provide GetItemsOfType<> (and many others) I thought of building my own:

[ConfigurationElementType(typeof(CustomCacheManagerData))]
public class MyCacheManager : ICacheManager
{
    //The same constructor as in CacheAppBlock - CacheManager, but it's public here:
    public MyCacheManager(Cache realCache, BackgroundScheduler scheduler, ExpirationPollTimer pollTimer)
    {
       this.realCache = realCache;
       this.scheduler = scheduler;
       this.pollTimer = pollTimer;
    }
    //the other code is basically copy/paste from CacheManager in EntLib, with some of my methods like:
    public T[] GetItemsOfType<T>()
    {
        return realCache.CurrentCacheState.Values.OfType<T>().ToArray();
    }
    //I also have some other custom code on the underlying Hashtable in realCache
}

The cofiguration part (the type part points to my class, encryption isn’t used):

<cachingConfiguration defaultCacheManager="SomeCacheManager">
    <cacheManagers>
      <add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000"
        numberToRemoveWhenScavenging="10" backingStoreName="Null Storage"
        type="MyNamespace.MyCacheManager, MyNamespace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
        name="SomeCacheManager" />
</cacheManagers>
    <backingStores>
      <add encryptionProviderName="" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="Null Storage" />
    </backingStores>
  </cachingConfiguration>

The problem I’m facing now is how to create MyCacheManager?
The:

mCityCacheManager = (MyCacheManager)CacheFactory.GetCacheManager("SomeCacheManager");

throws exception saying there’s no Constructor in MyCacheManager (but there is, same as in EntLib’s CacheManager only they are public in my class…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T19:08:03+00:00Added an answer on May 14, 2026 at 7:08 pm

    That’s because MyCacheManager isn’t exactly like the EntLib one! And I don’t mean the extra methods. Take a look at the declarations.

    Original CacheManager:

    [ConfigurationElementType(typeof(CacheManagerData))]
    public class CacheManager : IDisposable, ICacheManager
    

    MyCacheManager:

    [ConfigurationElementType(typeof(CustomCacheManagerData))]
    public class MyCacheManager : ICacheManager
    

    Other than the name difference (and you didn’t extend IDisposable), notice the element type attributes.

    You’re using (you have to) the Custom one. The custom one requires a constructor that takes a NameValueCollection as a parameter.

    public MyCacheManager(NameValueCollection collection)
    

    It is a generic configuration driver, so to speak, and as such it cannot be expected to know to create your instance with a 3 parameter constructor consisting of a Cache object, scheduler, and poll timer like you’ve got. Instead, it passes in these values (or anything you’ve got set as attributes in the configuration file) via a basic NameValueCollection which you’ll have to parse manually.

    See also: Create a custom caching manager for Enterprise Library 4

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since CS3 doesn't have a web service component, as previous versions had, is there
Since the keyboard is the interface we use to the computer, I've always thought
Is there a way to provide a method implementation (that bears the exact same
Since I started studying object-oriented programming, I frequently read articles/blogs saying functions are better,
Since both a Table Scan and a Clustered Index Scan essentially scan all records
Since Graduating from a very small school in 2006 with a badly shaped &
Since the WMI class Win32_OperatingSystem only includes OSArchitecture in Windows Vista, I quickly wrote
Since debate without meaningful terms is meaningless , I figured I would point at
Since Rails is not multithreaded (yet), it seems like a threaded web framework would
Since the only operations required for a container to be used in a stack

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.