Initializes a new instance of the MemoryCache class.
Assembly: System.Runtime.Caching (in System.Runtime.Caching.dll)
- Type: System.String
The name to use to look up configuration information.
Note It is not required for configuration information to exist for every name.
If a matching configuration entry exists, the configuration information is used to configure the MemoryCache instance. If a matching configuration entry does not exist, the name can be accessed through the Name property, because the specified name is associated with the MemoryCache instance. For information about memory cache configuration, see MemoryCacheElement.
- Type: System.Collections.Specialized.NameValueCollection
A collection of name/value pairs of configuration information to use for configuring the cache.
name is Nothing.
name is an empty string.
A value in the config collection is invalid.
A name or value in the config parameter could not be parsed.
When the MemoryCache class is initialized, it checks for configuration entries that might have been overridden by using the optional config parameter in the constructor. You can pass the following parameters in the config parameter. All values can be passed as integers.
When this constructor is invoked, configuration settings are first retrieved from application configuration files. If no configuration entries exist in the application configuration file, only the settings provided in config are applied. If the configuration entries in the application configuration exist, and if information is also passed in config, the information in the config overrides the information that is read from the configuration file.
The name value that is assigned to a cache instance is used in two ways:
To help you keep track of multiple cache instances when more than one instance exists.
To reference settings in the configuration file when the MemoryCache instance is initialized.
There is no mechanism to enforce unique names for cache instances. Therefore, it is possible to have multiple cache instances with the same name.
Do not create MemoryCache instances unless it is required. If you create cache instances in client and Web applications, the MemoryCache instances should be created early in the application life cycle. You must create only the number of cache instances that will be used in your application, and store references to the cache instances in variables that can be accessed globally. For example, in ASP.NET applications, you can store the references in application state. If you create only a single cache instance in your application, use the default cache and get a reference to it from the Default property when you need to access the cache.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.