Imported Upstream version 5.10.0.69

Former-commit-id: fc39669a0b707dd3c063977486506b6793da2890
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-01-29 19:03:06 +00:00
parent d8f8abd549
commit e2950ec768
6283 changed files with 453847 additions and 91879 deletions

View File

@@ -0,0 +1,90 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27108.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{F19CC87B-3230-42BF-8C1F-88F4F5EDE153}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Runtime.Caching", "ref\System.Runtime.Caching.csproj", "{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9EC38C79-BC41-4675-AB3D-A509BDC14FE0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Runtime.Caching", "src\System.Runtime.Caching.csproj", "{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{D4DA8C10-76FA-49D3-B4F2-BCB0C94330F6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Runtime.Caching.Tests", "tests\System.Runtime.Caching.Tests.csproj", "{397E49A7-EB26-4368-8F46-D78B98F4A971}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
netcoreapp-Windows_NT-Debug|Any CPU = netcoreapp-Windows_NT-Debug|Any CPU
netcoreapp-Windows_NT-Release|Any CPU = netcoreapp-Windows_NT-Release|Any CPU
netfx-Debug|Any CPU = netfx-Debug|Any CPU
netfx-Release|Any CPU = netfx-Release|Any CPU
netstandard-Debug|Any CPU = netstandard-Debug|Any CPU
netstandard-Release|Any CPU = netstandard-Release|Any CPU
netstandard-Windows_NT-Debug|Any CPU = netstandard-Windows_NT-Debug|Any CPU
netstandard-Windows_NT-Release|Any CPU = netstandard-Windows_NT-Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}.netcoreapp-Windows_NT-Debug|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}.netcoreapp-Windows_NT-Debug|Any CPU.Build.0 = netstandard-Release|Any CPU
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}.netcoreapp-Windows_NT-Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}.netcoreapp-Windows_NT-Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}.netfx-Debug|Any CPU.ActiveCfg = netfx-Debug|Any CPU
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}.netfx-Debug|Any CPU.Build.0 = netfx-Debug|Any CPU
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}.netfx-Release|Any CPU.ActiveCfg = netfx-Release|Any CPU
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}.netfx-Release|Any CPU.Build.0 = netfx-Release|Any CPU
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}.netstandard-Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}.netstandard-Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}.netstandard-Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}.netstandard-Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}.netstandard-Windows_NT-Debug|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}.netstandard-Windows_NT-Debug|Any CPU.Build.0 = netstandard-Release|Any CPU
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}.netstandard-Windows_NT-Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}.netstandard-Windows_NT-Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}.netcoreapp-Windows_NT-Debug|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}.netcoreapp-Windows_NT-Debug|Any CPU.Build.0 = netstandard-Release|Any CPU
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}.netcoreapp-Windows_NT-Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}.netcoreapp-Windows_NT-Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}.netfx-Debug|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}.netfx-Debug|Any CPU.Build.0 = netstandard-Release|Any CPU
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}.netfx-Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}.netfx-Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}.netstandard-Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}.netstandard-Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}.netstandard-Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}.netstandard-Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}.netstandard-Windows_NT-Debug|Any CPU.ActiveCfg = netstandard-Windows_NT-Debug|Any CPU
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}.netstandard-Windows_NT-Debug|Any CPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}.netstandard-Windows_NT-Release|Any CPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}.netstandard-Windows_NT-Release|Any CPU.Build.0 = netstandard-Windows_NT-Release|Any CPU
{397E49A7-EB26-4368-8F46-D78B98F4A971}.netcoreapp-Windows_NT-Debug|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Debug|Any CPU
{397E49A7-EB26-4368-8F46-D78B98F4A971}.netcoreapp-Windows_NT-Debug|Any CPU.Build.0 = netcoreapp-Windows_NT-Debug|Any CPU
{397E49A7-EB26-4368-8F46-D78B98F4A971}.netcoreapp-Windows_NT-Release|Any CPU.ActiveCfg = netcoreapp-Windows_NT-Release|Any CPU
{397E49A7-EB26-4368-8F46-D78B98F4A971}.netcoreapp-Windows_NT-Release|Any CPU.Build.0 = netcoreapp-Windows_NT-Release|Any CPU
{397E49A7-EB26-4368-8F46-D78B98F4A971}.netfx-Debug|Any CPU.ActiveCfg = netfx-Debug|Any CPU
{397E49A7-EB26-4368-8F46-D78B98F4A971}.netfx-Debug|Any CPU.Build.0 = netfx-Debug|Any CPU
{397E49A7-EB26-4368-8F46-D78B98F4A971}.netfx-Release|Any CPU.ActiveCfg = netfx-Release|Any CPU
{397E49A7-EB26-4368-8F46-D78B98F4A971}.netfx-Release|Any CPU.Build.0 = netfx-Release|Any CPU
{397E49A7-EB26-4368-8F46-D78B98F4A971}.netstandard-Debug|Any CPU.ActiveCfg = netfx-Release|Any CPU
{397E49A7-EB26-4368-8F46-D78B98F4A971}.netstandard-Debug|Any CPU.Build.0 = netfx-Release|Any CPU
{397E49A7-EB26-4368-8F46-D78B98F4A971}.netstandard-Release|Any CPU.ActiveCfg = netfx-Release|Any CPU
{397E49A7-EB26-4368-8F46-D78B98F4A971}.netstandard-Release|Any CPU.Build.0 = netfx-Release|Any CPU
{397E49A7-EB26-4368-8F46-D78B98F4A971}.netstandard-Windows_NT-Debug|Any CPU.ActiveCfg = netfx-Release|Any CPU
{397E49A7-EB26-4368-8F46-D78B98F4A971}.netstandard-Windows_NT-Debug|Any CPU.Build.0 = netfx-Release|Any CPU
{397E49A7-EB26-4368-8F46-D78B98F4A971}.netstandard-Windows_NT-Release|Any CPU.ActiveCfg = netfx-Release|Any CPU
{397E49A7-EB26-4368-8F46-D78B98F4A971}.netstandard-Windows_NT-Release|Any CPU.Build.0 = netfx-Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280} = {F19CC87B-3230-42BF-8C1F-88F4F5EDE153}
{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829} = {9EC38C79-BC41-4675-AB3D-A509BDC14FE0}
{397E49A7-EB26-4368-8F46-D78B98F4A971} = {D4DA8C10-76FA-49D3-B4F2-BCB0C94330F6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D3D6D992-CDEE-4C0C-83A6-E2EF77383E5C}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<!-- this assembly is inbox in desktop, do not version it unless you
plan on shipping a new desktop version out of band. Instead add API
to a different assembly. -->
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyKey>MSFT</AssemblyKey>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<ProjectReference Include="..\ref\System.Runtime.Caching.csproj">
<SupportedFramework>netcoreapp2.0;net45;$(AllXamarinFrameworks)</SupportedFramework>
</ProjectReference>
<ProjectReference Include="..\src\System.Runtime.Caching.csproj" />
<InboxOnTargetFramework Include="net45">
<AsFrameworkReference>true</AsFrameworkReference>
</InboxOnTargetFramework>
<InboxOnTargetFramework Include="$(AllXamarinFrameworks)" />
<File Include="$(PlaceHolderFile)">
<TargetPath>runtimes/win/lib/net45</TargetPath>
</File>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netstandard;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,187 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
namespace System.Runtime.Caching
{
public abstract partial class CacheEntryChangeMonitor : System.Runtime.Caching.ChangeMonitor
{
protected CacheEntryChangeMonitor() { }
public abstract System.Collections.ObjectModel.ReadOnlyCollection<string> CacheKeys { get; }
public abstract System.DateTimeOffset LastModified { get; }
public abstract string RegionName { get; }
}
public partial class CacheEntryRemovedArguments
{
public CacheEntryRemovedArguments(System.Runtime.Caching.ObjectCache source, System.Runtime.Caching.CacheEntryRemovedReason reason, System.Runtime.Caching.CacheItem cacheItem) { }
public System.Runtime.Caching.CacheItem CacheItem { get { throw null; } }
public System.Runtime.Caching.CacheEntryRemovedReason RemovedReason { get { throw null; } }
public System.Runtime.Caching.ObjectCache Source { get { throw null; } }
}
public delegate void CacheEntryRemovedCallback(System.Runtime.Caching.CacheEntryRemovedArguments arguments);
public enum CacheEntryRemovedReason
{
CacheSpecificEviction = 4,
ChangeMonitorChanged = 3,
Evicted = 2,
Expired = 1,
Removed = 0,
}
public partial class CacheEntryUpdateArguments
{
public CacheEntryUpdateArguments(System.Runtime.Caching.ObjectCache source, System.Runtime.Caching.CacheEntryRemovedReason reason, string key, string regionName) { }
public string Key { get { throw null; } }
public string RegionName { get { throw null; } }
public System.Runtime.Caching.CacheEntryRemovedReason RemovedReason { get { throw null; } }
public System.Runtime.Caching.ObjectCache Source { get { throw null; } }
public System.Runtime.Caching.CacheItem UpdatedCacheItem { get { throw null; } set { } }
public System.Runtime.Caching.CacheItemPolicy UpdatedCacheItemPolicy { get { throw null; } set { } }
}
public delegate void CacheEntryUpdateCallback(System.Runtime.Caching.CacheEntryUpdateArguments arguments);
public partial class CacheItem
{
public CacheItem(string key) { }
public CacheItem(string key, object value) { }
public CacheItem(string key, object value, string regionName) { }
public string Key { get { throw null; } set { } }
public string RegionName { get { throw null; } set { } }
public object Value { get { throw null; } set { } }
}
public partial class CacheItemPolicy
{
public CacheItemPolicy() { }
public System.DateTimeOffset AbsoluteExpiration { get { throw null; } set { } }
public System.Collections.ObjectModel.Collection<System.Runtime.Caching.ChangeMonitor> ChangeMonitors { get { throw null; } }
public System.Runtime.Caching.CacheItemPriority Priority { get { throw null; } set { } }
public System.Runtime.Caching.CacheEntryRemovedCallback RemovedCallback { get { throw null; } set { } }
public System.TimeSpan SlidingExpiration { get { throw null; } set { } }
public System.Runtime.Caching.CacheEntryUpdateCallback UpdateCallback { get { throw null; } set { } }
}
public enum CacheItemPriority
{
Default = 0,
NotRemovable = 1,
}
public abstract partial class ChangeMonitor : System.IDisposable
{
protected ChangeMonitor() { }
public bool HasChanged { get { throw null; } }
public bool IsDisposed { get { throw null; } }
public abstract string UniqueId { get; }
public void Dispose() { }
protected abstract void Dispose(bool disposing);
protected void InitializationComplete() { }
public void NotifyOnChanged(System.Runtime.Caching.OnChangedCallback onChangedCallback) { }
protected void OnChanged(object state) { }
}
[System.FlagsAttribute]
public enum DefaultCacheCapabilities
{
AbsoluteExpirations = 8,
CacheEntryChangeMonitors = 4,
CacheEntryRemovedCallback = 64,
CacheEntryUpdateCallback = 32,
CacheRegions = 128,
InMemoryProvider = 1,
None = 0,
OutOfProcessProvider = 2,
SlidingExpirations = 16,
}
public abstract partial class FileChangeMonitor : System.Runtime.Caching.ChangeMonitor
{
protected FileChangeMonitor() { }
public abstract System.Collections.ObjectModel.ReadOnlyCollection<string> FilePaths { get; }
public abstract System.DateTimeOffset LastModified { get; }
}
public sealed partial class HostFileChangeMonitor : System.Runtime.Caching.FileChangeMonitor
{
public HostFileChangeMonitor(System.Collections.Generic.IList<string> filePaths) { }
public override System.Collections.ObjectModel.ReadOnlyCollection<string> FilePaths { get { throw null; } }
public override System.DateTimeOffset LastModified { get { throw null; } }
public override string UniqueId { get { throw null; } }
protected override void Dispose(bool disposing) { }
}
public partial class MemoryCache : System.Runtime.Caching.ObjectCache, System.Collections.IEnumerable, System.IDisposable
{
public MemoryCache(string name, System.Collections.Specialized.NameValueCollection config=null) { }
public MemoryCache(string name, System.Collections.Specialized.NameValueCollection config, bool ignoreConfigSection) { }
public long CacheMemoryLimit { get { throw null; } }
public static System.Runtime.Caching.MemoryCache Default { get { throw null; } }
public override System.Runtime.Caching.DefaultCacheCapabilities DefaultCacheCapabilities { get { throw null; } }
public override object this[string key] { get { throw null; } set { } }
public override string Name { get { throw null; } }
public long PhysicalMemoryLimit { get { throw null; } }
public System.TimeSpan PollingInterval { get { throw null; } }
public override bool Add(System.Runtime.Caching.CacheItem item, System.Runtime.Caching.CacheItemPolicy policy) { throw null; }
public override System.Runtime.Caching.CacheItem AddOrGetExisting(System.Runtime.Caching.CacheItem item, System.Runtime.Caching.CacheItemPolicy policy) { throw null; }
public override object AddOrGetExisting(string key, object value, System.DateTimeOffset absoluteExpiration, string regionName=null) { throw null; }
public override object AddOrGetExisting(string key, object value, System.Runtime.Caching.CacheItemPolicy policy, string regionName=null) { throw null; }
public override bool Contains(string key, string regionName=null) { throw null; }
public override System.Runtime.Caching.CacheEntryChangeMonitor CreateCacheEntryChangeMonitor(System.Collections.Generic.IEnumerable<string> keys, string regionName=null) { throw null; }
public void Dispose() { }
public override object Get(string key, string regionName=null) { throw null; }
public override System.Runtime.Caching.CacheItem GetCacheItem(string key, string regionName=null) { throw null; }
public override long GetCount(string regionName=null) { throw null; }
protected override System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, object>> GetEnumerator() { throw null; }
public long GetLastSize(string regionName=null) { throw null; }
public override System.Collections.Generic.IDictionary<string, object> GetValues(System.Collections.Generic.IEnumerable<string> keys, string regionName=null) { throw null; }
public object Remove(string key, System.Runtime.Caching.CacheEntryRemovedReason reason, string regionName=null) { throw null; }
public override object Remove(string key, string regionName=null) { throw null; }
public override void Set(System.Runtime.Caching.CacheItem item, System.Runtime.Caching.CacheItemPolicy policy) { }
public override void Set(string key, object value, System.DateTimeOffset absoluteExpiration, string regionName=null) { }
public override void Set(string key, object value, System.Runtime.Caching.CacheItemPolicy policy, string regionName=null) { }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
public long Trim(int percent) { throw null; }
}
public abstract partial class ObjectCache : System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>, System.Collections.IEnumerable
{
public static readonly System.DateTimeOffset InfiniteAbsoluteExpiration;
public static readonly System.TimeSpan NoSlidingExpiration;
protected ObjectCache() { }
public abstract System.Runtime.Caching.DefaultCacheCapabilities DefaultCacheCapabilities { get; }
public static System.IServiceProvider Host { get { throw null; } set { } }
public abstract object this[string key] { get; set; }
public abstract string Name { get; }
public virtual bool Add(System.Runtime.Caching.CacheItem item, System.Runtime.Caching.CacheItemPolicy policy) { throw null; }
public virtual bool Add(string key, object value, System.DateTimeOffset absoluteExpiration, string regionName=null) { throw null; }
public virtual bool Add(string key, object value, System.Runtime.Caching.CacheItemPolicy policy, string regionName=null) { throw null; }
public abstract System.Runtime.Caching.CacheItem AddOrGetExisting(System.Runtime.Caching.CacheItem value, System.Runtime.Caching.CacheItemPolicy policy);
public abstract object AddOrGetExisting(string key, object value, System.DateTimeOffset absoluteExpiration, string regionName=null);
public abstract object AddOrGetExisting(string key, object value, System.Runtime.Caching.CacheItemPolicy policy, string regionName=null);
public abstract bool Contains(string key, string regionName=null);
public abstract System.Runtime.Caching.CacheEntryChangeMonitor CreateCacheEntryChangeMonitor(System.Collections.Generic.IEnumerable<string> keys, string regionName=null);
public abstract object Get(string key, string regionName=null);
public abstract System.Runtime.Caching.CacheItem GetCacheItem(string key, string regionName=null);
public abstract long GetCount(string regionName=null);
protected abstract System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, object>> GetEnumerator();
public abstract System.Collections.Generic.IDictionary<string, object> GetValues(System.Collections.Generic.IEnumerable<string> keys, string regionName=null);
public virtual System.Collections.Generic.IDictionary<string, object> GetValues(string regionName, params string[] keys) { throw null; }
public abstract object Remove(string key, string regionName=null);
public abstract void Set(System.Runtime.Caching.CacheItem item, System.Runtime.Caching.CacheItemPolicy policy);
public abstract void Set(string key, object value, System.DateTimeOffset absoluteExpiration, string regionName=null);
public abstract void Set(string key, object value, System.Runtime.Caching.CacheItemPolicy policy, string regionName=null);
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, object>> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.GetEnumerator() { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
public delegate void OnChangedCallback(object state);
}
namespace System.Runtime.Caching.Hosting
{
public partial interface IApplicationIdentifier
{
string GetApplicationId();
}
public partial interface IFileChangeNotificationSystem
{
void StartMonitoring(string filePath, System.Runtime.Caching.OnChangedCallback onChangedCallback, out object state, out System.DateTimeOffset lastWriteTime, out long fileSize);
void StopMonitoring(string filePath, object state);
}
public partial interface IMemoryCacheManager
{
void ReleaseCache(System.Runtime.Caching.MemoryCache cache);
void UpdateCacheSize(long size, System.Runtime.Caching.MemoryCache cache);
}
}

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<PropertyGroup>
<ProjectGuid>{3B7A97BD-F4DC-4FF9-AB6D-3B714E5D9280}</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<Compile Include="System.Runtime.Caching.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PackageConfigurations>
netstandard;
netcoreapp2.0-Windows_NT;
</PackageConfigurations>
<BuildConfigurations>
$(PackageConfigurations);
netcoreapp-Windows_NT;
_netfx;
</BuildConfigurations>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,186 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Config_unable_to_get_section" xml:space="preserve">
<value>Unable to retrieve configuration section '{0}'.</value>
</data>
<data name="TimeSpan_invalid_format" xml:space="preserve">
<value>Invalid configuration: {0}="{1}". The {0} value must be a time interval that can be parsed by System.TimeSpan.Parse.</value>
</data>
<data name="Value_must_be_non_negative_integer" xml:space="preserve">
<value>Invalid configuration: {0}="{1}". The {0} value must be a non-negative 32-bit integer.</value>
</data>
<data name="Value_must_be_positive_integer" xml:space="preserve">
<value>Invalid configuration: {0}="{1}". The {0} value must be a positive 32-bit integer.</value>
</data>
<data name="Value_too_big" xml:space="preserve">
<value>Invalid configuration: {0}="{1}". The {0} value cannot be greater than '{2}'.</value>
</data>
<data name="Empty_collection" xml:space="preserve">
<value>The collection '{0}' is empty.</value>
</data>
<data name="Collection_contains_null_element" xml:space="preserve">
<value>The collection '{0}' contains a null element.</value>
</data>
<data name="Collection_contains_null_or_empty_string" xml:space="preserve">
<value>The collection '{0}' contains a null or empty string.</value>
</data>
<data name="Method_already_invoked" xml:space="preserve">
<value>The method has already been invoked, and can only be invoked once.</value>
</data>
<data name="Property_already_set" xml:space="preserve">
<value>The property has already been set, and can only be set once.</value>
</data>
<data name="Invalid_state" xml:space="preserve">
<value>Invalid state.</value>
</data>
<data name="Init_not_complete" xml:space="preserve">
<value>Initialization has not completed yet. The InitializationComplete method must be invoked before Dispose is invoked.</value>
</data>
<data name="Default_is_reserved" xml:space="preserve">
<value>Default is a reserved MemoryCache name.</value>
</data>
<data name="Invalid_expiration_combination" xml:space="preserve">
<value>AbsoluteExpiration must be DateTimeOffset.MaxValue or SlidingExpiration must be TimeSpan.Zero.</value>
</data>
<data name="Invalid_callback_combination" xml:space="preserve">
<value>Only one callback can be specified. Either RemovedCallback or UpdateCallback must be null.</value>
</data>
<data name="Invalid_argument_combination" xml:space="preserve">
<value>One of the following parameters must be specified: dependencies, absoluteExpiration, slidingExpiration.</value>
</data>
<data name="Update_callback_must_be_null" xml:space="preserve">
<value>CacheItemUpdateCallback must be null.</value>
</data>
<data name="Argument_out_of_range" xml:space="preserve">
<value>'{0}' must be greater than or equal to '{1}' and less than or equal to '{2}'.</value>
</data>
<data name="Empty_string_invalid" xml:space="preserve">
<value>An empty string is invalid.</value>
</data>
<data name="RegionName_not_supported" xml:space="preserve">
<value>The parameter regionName must be null.</value>
</data>
<data name="Value_must_be_boolean" xml:space="preserve">
<value>Invalid configuration: {0}="{1}". The {0} value must be a boolean.</value>
</data>
<data name="PlatformNotSupported_Caching" xml:space="preserve">
<value>System.Runtime.Caching is not supported on this platform.</value>
</data>
</root>

View File

@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<AssemblyName>System.Runtime.Caching</AssemblyName>
<ProjectGuid>{A7B6FB6E-F484-42D7-8A5E-F7D0DCC03829}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- Although we have a netstandard configuration, we know we are not currently UAP compatible-->
<UWPCompatible>false</UWPCompatible>
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetsWindows)' != 'true'">SR.PlatformNotSupported_Caching</GeneratePlatformNotSupportedAssemblyMessage>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp2.0-Windows_NT-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp2.0-Windows_NT-Release|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<ItemGroup Condition="'$(TargetsWindows)' == 'true'">
<Compile Include="System\Runtime\Caching\_shims.cs" />
<Compile Include="System\Runtime\Caching\CacheEntryChangeMonitor.cs" />
<Compile Include="System\Runtime\Caching\CacheEntryRemovedArguments.cs" />
<Compile Include="System\Runtime\Caching\CacheEntryRemovedCallback.cs" />
<Compile Include="System\Runtime\Caching\CacheEntryRemovedReason.cs" />
<Compile Include="System\Runtime\Caching\CacheEntryUpdateArguments.cs" />
<Compile Include="System\Runtime\Caching\CacheEntryUpdateCallback.cs" />
<Compile Include="System\Runtime\Caching\CacheExpires.cs" />
<Compile Include="System\Runtime\Caching\CacheItem.cs" />
<Compile Include="System\Runtime\Caching\CacheItemPolicy.cs" />
<Compile Include="System\Runtime\Caching\CacheItemPriority.cs" />
<Compile Include="System\Runtime\Caching\CacheMemoryMonitor.cs" />
<Compile Include="System\Runtime\Caching\CacheUsage.cs" />
<Compile Include="System\Runtime\Caching\ChangeMonitor.cs" />
<Compile Include="System\Runtime\Caching\Dbg.cs" />
<Compile Include="System\Runtime\Caching\DefaultCacheCapabilities.cs" />
<Compile Include="System\Runtime\Caching\EntryState.cs" />
<Compile Include="System\Runtime\Caching\FileChangeMonitor.cs" />
<Compile Include="System\Runtime\Caching\FileChangeNotificationSystem.cs" />
<Compile Include="System\Runtime\Caching\HostFileChangeMonitor.cs" />
<Compile Include="System\Runtime\Caching\MemoryCache.cs" />
<Compile Include="System\Runtime\Caching\MemoryCacheEntry.cs" />
<Compile Include="System\Runtime\Caching\MemoryCacheEntryChangeMonitor.cs" />
<Compile Include="System\Runtime\Caching\MemoryCacheKey.cs" />
<Compile Include="System\Runtime\Caching\MemoryCacheKeyEqualityComparer.cs" />
<Compile Include="System\Runtime\Caching\MemoryCacheStatistics.cs" />
<Compile Include="System\Runtime\Caching\MemoryCacheStore.cs" />
<Compile Include="System\Runtime\Caching\MemoryMonitor.cs" />
<Compile Include="System\Runtime\Caching\ObjectCache.cs" />
<Compile Include="System\Runtime\Caching\OnChangedCallback.cs" />
<Compile Include="System\Runtime\Caching\PerfCounterName.cs" />
<Compile Include="System\Runtime\Caching\PhysicalMemoryMonitor.cs" />
<Compile Include="System\Runtime\Caching\SafeBitVector32.cs" />
<Compile Include="System\Runtime\Caching\SRef.cs" />
<Compile Include="System\Runtime\Caching\Configuration\CachingSectionGroup.cs" />
<Compile Include="System\Runtime\Caching\Configuration\ConfigUtil.cs" />
<Compile Include="System\Runtime\Caching\Configuration\MemoryCacheElement.cs" />
<Compile Include="System\Runtime\Caching\Configuration\MemoryCacheSection.cs" />
<Compile Include="System\Runtime\Caching\Configuration\MemoryCacheSettingsCollection.cs" />
<Compile Include="System\Runtime\Caching\Hosting\IApplicationIdentifier.cs" />
<Compile Include="System\Runtime\Caching\Hosting\IFileChangeNotificationSystem.cs" />
<Compile Include="System\Runtime\Caching\Hosting\IMemoryCacheManager.cs" />
<Compile Include="System\Runtime\Caching\Resources\RH.cs" />
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.GlobalMemoryStatusEx.cs">
<Link>Common\Interop\Windows\kernel32\Interop.GlobalMemoryStatusEx.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.MEMORY_BASIC_INFO.cs">
<Link>Common\Interop\Windows\kernel32\Interop.MEMORY_BASIC_INFO.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\Interop.Libraries.cs">
<Link>Common\Interop\Windows\Interop.Libraries.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Win32.Primitives" />
<Reference Include="Microsoft.Win32.Registry" />
<Reference Include="System.Collections" />
<Reference Include="System.Collections.Specialized" />
<Reference Include="System.ComponentModel" />
<Reference Include="System.ComponentModel.Primitives" />
<Reference Include="System.ComponentModel.TypeConverter" />
<Reference Include="System.Configuration.ConfigurationManager" />
<Reference Include="System.Diagnostics.Debug" />
<Reference Include="System.Diagnostics.Process" />
<Reference Include="System.Diagnostics.StackTrace" />
<Reference Include="System.Diagnostics.Tools" />
<Reference Include="System.Diagnostics.TraceSource" />
<Reference Include="System.IO" />
<Reference Include="System.IO.FileSystem" />
<Reference Include="System.IO.FileSystem.Watcher" />
<Reference Include="System.Resources.ResourceManager" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Runtime.InteropServices" />
<Reference Include="System.Security.Permissions" />
<Reference Include="System.Security.Principal.Windows" />
<Reference Include="System.Threading" />
<Reference Include="System.Threading.AccessControl" />
<Reference Include="System.Threading.Thread" />
<Reference Include="System.Threading.ThreadPool" />
<Reference Include="System.Threading.Timer" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -0,0 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace System.Runtime.Caching
{
public abstract class CacheEntryChangeMonitor : ChangeMonitor
{
public abstract ReadOnlyCollection<string> CacheKeys { get; }
public abstract DateTimeOffset LastModified { get; }
public abstract String RegionName { get; }
}
}

View File

@@ -0,0 +1,43 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.Runtime.Caching
{
public class CacheEntryRemovedArguments
{
private CacheItem _cacheItem;
private ObjectCache _source;
private CacheEntryRemovedReason _reason;
public CacheItem CacheItem
{
get { return _cacheItem; }
}
public CacheEntryRemovedReason RemovedReason
{
get { return _reason; }
}
public ObjectCache Source
{
get { return _source; }
}
public CacheEntryRemovedArguments(ObjectCache source, CacheEntryRemovedReason reason, CacheItem cacheItem)
{
if (source == null)
{
throw new ArgumentNullException("source");
}
if (cacheItem == null)
{
throw new ArgumentNullException("cacheItem");
}
_source = source;
_reason = reason;
_cacheItem = cacheItem;
}
}
}

View File

@@ -0,0 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace System.Runtime.Caching
{
public delegate void CacheEntryRemovedCallback(CacheEntryRemovedArguments arguments);
}

View File

@@ -0,0 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace System.Runtime.Caching
{
public enum CacheEntryRemovedReason
{
Removed = 0, //Explicitly removed via API call
Expired,
Evicted, //Evicted to free up space
ChangeMonitorChanged, //An associated programmatic dependency triggered eviction
CacheSpecificEviction //Catch-all for custom providers
}
}

View File

@@ -0,0 +1,66 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace System.Runtime.Caching
{
public class CacheEntryUpdateArguments
{
private String _key;
private CacheEntryRemovedReason _reason;
private String _regionName;
private ObjectCache _source;
private CacheItem _updatedCacheItem;
private CacheItemPolicy _updatedCacheItemPolicy;
public String Key
{
get { return _key; }
}
public CacheEntryRemovedReason RemovedReason
{
get { return _reason; }
}
public String RegionName
{
get { return _regionName; }
}
public ObjectCache Source
{
get { return _source; }
}
public CacheItem UpdatedCacheItem
{
get { return _updatedCacheItem; }
set { _updatedCacheItem = value; }
}
public CacheItemPolicy UpdatedCacheItemPolicy
{
get { return _updatedCacheItemPolicy; }
set { _updatedCacheItemPolicy = value; }
}
public CacheEntryUpdateArguments(ObjectCache source, CacheEntryRemovedReason reason, String key, String regionName)
{
if (source == null)
{
throw new ArgumentNullException("source");
}
if (key == null)
{
throw new ArgumentNullException("key");
}
_source = source;
_reason = reason;
_key = key;
_regionName = regionName;
}
}
}

View File

@@ -0,0 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace System.Runtime.Caching
{
public delegate void CacheEntryUpdateCallback(CacheEntryUpdateArguments arguments);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace System.Runtime.Caching
{
public class CacheItem
{
public string Key { get; set; }
public object Value { get; set; }
public string RegionName { get; set; }
private CacheItem() { } // hide default constructor
public CacheItem(string key)
{
Key = key;
}
public CacheItem(string key, object value) : this(key)
{
Value = value;
}
public CacheItem(string key, object value, string regionName) : this(key, value)
{
RegionName = regionName;
}
}
}

View File

@@ -0,0 +1,68 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.ObjectModel;
namespace System.Runtime.Caching
{
public class CacheItemPolicy
{
private DateTimeOffset _absExpiry;
private TimeSpan _sldExpiry;
private Collection<ChangeMonitor> _changeMonitors;
private CacheItemPriority _priority;
private CacheEntryRemovedCallback _removedCallback;
private CacheEntryUpdateCallback _updateCallback;
public DateTimeOffset AbsoluteExpiration
{
get { return _absExpiry; }
set { _absExpiry = value; }
}
public Collection<ChangeMonitor> ChangeMonitors
{
get
{
if (_changeMonitors == null)
{
_changeMonitors = new Collection<ChangeMonitor>();
}
return _changeMonitors;
}
}
public CacheItemPriority Priority
{
get { return _priority; }
set { _priority = value; }
}
public CacheEntryRemovedCallback RemovedCallback
{
get { return _removedCallback; }
set { _removedCallback = value; }
}
public TimeSpan SlidingExpiration
{
get { return _sldExpiry; }
set { _sldExpiry = value; }
}
public CacheEntryUpdateCallback UpdateCallback
{
get { return _updateCallback; }
set { _updateCallback = value; }
}
public CacheItemPolicy()
{
_absExpiry = ObjectCache.InfiniteAbsoluteExpiration;
_sldExpiry = ObjectCache.NoSlidingExpiration;
_priority = CacheItemPriority.Default;
}
}
}

View File

@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
namespace System.Runtime.Caching
{
public enum CacheItemPriority
{
Default = 0,
NotRemovable
}
}

View File

@@ -0,0 +1,298 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.Caching.Configuration;
using System.Runtime.Caching.Hosting;
using System.Diagnostics;
using System.Security;
using System.Security.Permissions;
using System.Threading;
namespace System.Runtime.Caching
{
// CacheMemoryMonitor uses the internal System.SizedReference type to determine
// the size of the cache itselt, and helps us know when to drop entries to avoid
// exceeding the cache's memory limit. The limit is configurable (see ConfigUtil.cs).
internal sealed class CacheMemoryMonitor : MemoryMonitor, IDisposable
{
private const long PRIVATE_BYTES_LIMIT_2GB = 800 * MEGABYTE;
private const long PRIVATE_BYTES_LIMIT_3GB = 1800 * MEGABYTE;
private const long PRIVATE_BYTES_LIMIT_64BIT = 1L * TERABYTE;
private const int SAMPLE_COUNT = 2;
private static IMemoryCacheManager s_memoryCacheManager;
private static long s_autoPrivateBytesLimit = -1;
private static long s_effectiveProcessMemoryLimit = -1;
private MemoryCache _memoryCache;
private long[] _cacheSizeSamples;
private DateTime[] _cacheSizeSampleTimes;
private int _idx;
private SRefMultiple _sizedRefMultiple;
private int _gen2Count;
private long _memoryLimit;
internal long MemoryLimit
{
get { return _memoryLimit; }
}
private CacheMemoryMonitor()
{
// hide default ctor
}
internal CacheMemoryMonitor(MemoryCache memoryCache, int cacheMemoryLimitMegabytes)
{
_memoryCache = memoryCache;
_gen2Count = GC.CollectionCount(2);
_cacheSizeSamples = new long[SAMPLE_COUNT];
_cacheSizeSampleTimes = new DateTime[SAMPLE_COUNT];
if (memoryCache.UseMemoryCacheManager)
{
InitMemoryCacheManager(); // This magic thing connects us to ObjectCacheHost magically. :/
}
InitDisposableMembers(cacheMemoryLimitMegabytes);
}
private void InitDisposableMembers(int cacheMemoryLimitMegabytes)
{
bool dispose = true;
try
{
_sizedRefMultiple = new SRefMultiple(_memoryCache.AllSRefTargets);
SetLimit(cacheMemoryLimitMegabytes);
InitHistory();
dispose = false;
}
finally
{
if (dispose)
{
Dispose();
}
}
}
// Auto-generate the private bytes limit:
// - On 64bit, the auto value is MIN(60% physical_ram, 1 TB)
// - On x86, for 2GB, the auto value is MIN(60% physical_ram, 800 MB)
// - On x86, for 3GB, the auto value is MIN(60% physical_ram, 1800 MB)
//
// - If it's not a hosted environment (e.g. console app), the 60% in the above
// formulas will become 100% because in un-hosted environment we don't launch
// other processes such as compiler, etc.
private static long AutoPrivateBytesLimit
{
get
{
long memoryLimit = s_autoPrivateBytesLimit;
if (memoryLimit == -1)
{
bool is64bit = (IntPtr.Size == 8);
long totalPhysical = TotalPhysical;
long totalVirtual = TotalVirtual;
if (totalPhysical != 0)
{
long recommendedPrivateByteLimit;
if (is64bit)
{
recommendedPrivateByteLimit = PRIVATE_BYTES_LIMIT_64BIT;
}
else
{
// Figure out if it's 2GB or 3GB
if (totalVirtual > 2 * GIGABYTE)
{
recommendedPrivateByteLimit = PRIVATE_BYTES_LIMIT_3GB;
}
else
{
recommendedPrivateByteLimit = PRIVATE_BYTES_LIMIT_2GB;
}
}
// use 60% of physical RAM
long usableMemory = totalPhysical * 3 / 5;
memoryLimit = Math.Min(usableMemory, recommendedPrivateByteLimit);
}
else
{
// If GlobalMemoryStatusEx fails, we'll use these as our auto-gen private bytes limit
memoryLimit = is64bit ? PRIVATE_BYTES_LIMIT_64BIT : PRIVATE_BYTES_LIMIT_2GB;
}
Interlocked.Exchange(ref s_autoPrivateBytesLimit, memoryLimit);
}
return memoryLimit;
}
}
public void Dispose()
{
SRefMultiple sref = _sizedRefMultiple;
if (sref != null && Interlocked.CompareExchange(ref _sizedRefMultiple, null, sref) == sref)
{
sref.Dispose();
}
IMemoryCacheManager memoryCacheManager = s_memoryCacheManager;
if (memoryCacheManager != null)
{
memoryCacheManager.ReleaseCache(_memoryCache);
}
}
internal static long EffectiveProcessMemoryLimit
{
get
{
long memoryLimit = s_effectiveProcessMemoryLimit;
if (memoryLimit == -1)
{
memoryLimit = AutoPrivateBytesLimit;
Interlocked.Exchange(ref s_effectiveProcessMemoryLimit, memoryLimit);
}
return memoryLimit;
}
}
protected override int GetCurrentPressure()
{
// Call GetUpdatedTotalCacheSize to update the total
// cache size, if there has been a recent Gen 2 Collection.
// This update must happen, otherwise the CacheManager won't
// know the total cache size.
int gen2Count = GC.CollectionCount(2);
SRefMultiple sref = _sizedRefMultiple;
if (gen2Count != _gen2Count && sref != null)
{
// update _gen2Count
_gen2Count = gen2Count;
// the SizedRef is only updated after a Gen2 Collection
// increment the index (it's either 1 or 0)
Dbg.Assert(SAMPLE_COUNT == 2);
_idx = _idx ^ 1;
// remember the sample time
_cacheSizeSampleTimes[_idx] = DateTime.UtcNow;
// remember the sample value
_cacheSizeSamples[_idx] = sref.ApproximateSize;
#if DEBUG
Dbg.Trace("MemoryCacheStats", "SizedRef.ApproximateSize=" + _cacheSizeSamples[_idx]);
#endif
IMemoryCacheManager memoryCacheManager = s_memoryCacheManager;
if (memoryCacheManager != null)
{
memoryCacheManager.UpdateCacheSize(_cacheSizeSamples[_idx], _memoryCache);
}
}
// if there's no memory limit, then there's nothing more to do
if (_memoryLimit <= 0)
{
return 0;
}
long cacheSize = _cacheSizeSamples[_idx];
// use _memoryLimit as an upper bound so that pressure is a percentage (between 0 and 100, inclusive).
if (cacheSize > _memoryLimit)
{
cacheSize = _memoryLimit;
}
// PerfCounter: Cache Percentage Process Memory Limit Used
// = memory used by this process / process memory limit at pressureHigh
// Set private bytes used in kilobytes because the counter is a DWORD
// PerfCounters.SetCounter(AppPerfCounter.CACHE_PERCENT_PROC_MEM_LIMIT_USED, (int)(cacheSize >> KILOBYTE_SHIFT));
int result = (int)(cacheSize * 100 / _memoryLimit);
return result;
}
internal override int GetPercentToTrim(DateTime lastTrimTime, int lastTrimPercent)
{
int percent = 0;
if (IsAboveHighPressure())
{
long cacheSize = _cacheSizeSamples[_idx];
if (cacheSize > _memoryLimit)
{
percent = Math.Min(100, (int)((cacheSize - _memoryLimit) * 100L / cacheSize));
}
#if PERF
Debug.WriteLine(String.Format("CacheMemoryMonitor.GetPercentToTrim: percent={0:N}, lastTrimPercent={1:N}\n",
percent,
lastTrimPercent));
#endif
}
return percent;
}
internal void SetLimit(int cacheMemoryLimitMegabytes)
{
long cacheMemoryLimit = cacheMemoryLimitMegabytes;
cacheMemoryLimit = cacheMemoryLimit << MEGABYTE_SHIFT;
_memoryLimit = 0;
// never override what the user specifies as the limit;
// only call AutoPrivateBytesLimit when the user does not specify one.
if (cacheMemoryLimit == 0 && _memoryLimit == 0)
{
// Zero means we impose a limit
_memoryLimit = EffectiveProcessMemoryLimit;
}
else if (cacheMemoryLimit != 0 && _memoryLimit != 0)
{
// Take the min of "cache memory limit" and the host's "process memory limit".
_memoryLimit = Math.Min(_memoryLimit, cacheMemoryLimit);
}
else if (cacheMemoryLimit != 0)
{
// _memoryLimit is 0, but "cache memory limit" is non-zero, so use it as the limit
_memoryLimit = cacheMemoryLimit;
}
Dbg.Trace("MemoryCacheStats", "CacheMemoryMonitor.SetLimit: _memoryLimit=" + (_memoryLimit >> MEGABYTE_SHIFT) + "Mb");
if (_memoryLimit > 0)
{
_pressureHigh = 100;
_pressureLow = 80;
}
else
{
_pressureHigh = 99;
_pressureLow = 97;
}
Dbg.Trace("MemoryCacheStats", "CacheMemoryMonitor.SetLimit: _pressureHigh=" + _pressureHigh +
", _pressureLow=" + _pressureLow);
}
private static void InitMemoryCacheManager()
{
if (s_memoryCacheManager == null)
{
IMemoryCacheManager memoryCacheManager = null;
IServiceProvider host = ObjectCache.Host;
if (host != null)
{
memoryCacheManager = host.GetService(typeof(IMemoryCacheManager)) as IMemoryCacheManager;
}
if (memoryCacheManager != null)
{
Interlocked.CompareExchange(ref s_memoryCacheManager, memoryCacheManager, null);
}
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More