You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
parent
e49d6f06c0
commit
536cd135cc
@ -26,10 +26,6 @@ namespace System.Web.Caching {
|
||||
using System.Runtime.Caching;
|
||||
#endif
|
||||
|
||||
internal interface ICacheDependencyChanged {
|
||||
void DependencyChanged(Object sender, EventArgs e);
|
||||
}
|
||||
|
||||
|
||||
/// <devdoc>
|
||||
/// <para>The <see langword='CacheDependency'/> class tracks cache dependencies, which can be files,
|
||||
@ -50,7 +46,7 @@ namespace System.Web.Caching {
|
||||
string _uniqueID; // used by HttpCachePolicy for the ETag
|
||||
object _depFileInfos; // files to monitor for changes, either a DepFileInfo or array of DepFileInfos
|
||||
object _entries; // cache entries we are dependent on, either a string or array of strings
|
||||
ICacheDependencyChanged _objNotify; // Associated object to notify when a change occurs
|
||||
Action<Object, EventArgs> _objNotify; // Associated object to notify when a change occurs
|
||||
SafeBitVector32 _bits; // status bits for ready, used, changed, disposed
|
||||
DateTime _utcLastModified; // Time of last modified item
|
||||
#if USE_MEMORY_CACHE
|
||||
@ -59,7 +55,7 @@ namespace System.Web.Caching {
|
||||
#endif
|
||||
|
||||
static readonly string[] s_stringsEmpty;
|
||||
static readonly CacheEntry[] s_entriesEmpty;
|
||||
static readonly DepCacheInfo[] s_entriesEmpty;
|
||||
static readonly CacheDependency s_dependencyEmpty;
|
||||
static readonly DepFileInfo[] s_depFileInfosEmpty;
|
||||
|
||||
@ -78,9 +74,14 @@ namespace System.Web.Caching {
|
||||
internal FileAttributesData _fad;
|
||||
}
|
||||
|
||||
internal class DepCacheInfo {
|
||||
internal CacheStoreProvider _cacheStore;
|
||||
internal string _key;
|
||||
}
|
||||
|
||||
static CacheDependency() {
|
||||
s_stringsEmpty = new string[0];
|
||||
s_entriesEmpty = new CacheEntry[0];
|
||||
s_entriesEmpty = new DepCacheInfo[0];
|
||||
s_dependencyEmpty = new CacheDependency(0);
|
||||
s_depFileInfosEmpty = new DepFileInfo[0];
|
||||
}
|
||||
@ -205,7 +206,7 @@ namespace System.Web.Caching {
|
||||
void InitForMemoryCache(bool isPublic, string[] filenamesArg, string[] cachekeysArg, CacheDependency dependency, DateTime utcStart) {
|
||||
bool dispose = true;
|
||||
try {
|
||||
MemCache memCache = HttpRuntime.CacheInternal as MemCache;
|
||||
MemCache memCache = HttpRuntime.InternalCache as MemCache;
|
||||
_bits = new SafeBitVector32(0);
|
||||
_utcLastModified = DateTime.MinValue;
|
||||
IList<String> files = filenamesArg;
|
||||
@ -308,9 +309,9 @@ namespace System.Web.Caching {
|
||||
}
|
||||
#endif
|
||||
DepFileInfo[] depFileInfos = s_depFileInfosEmpty;
|
||||
CacheEntry[] depEntries = s_entriesEmpty;
|
||||
DepCacheInfo[] depEntries = s_entriesEmpty;
|
||||
string [] filenames, cachekeys;
|
||||
CacheInternal cacheInternal;
|
||||
CacheStoreProvider cache;
|
||||
|
||||
_bits = new SafeBitVector32(0);
|
||||
|
||||
@ -420,13 +421,13 @@ namespace System.Web.Caching {
|
||||
|
||||
// copy cache entries
|
||||
if (d_entries != null) {
|
||||
if (d_entries is CacheEntry) {
|
||||
depEntries = new CacheEntry[1] {(CacheEntry) (d_entries)};
|
||||
if (d_entries is DepCacheInfo) {
|
||||
depEntries = new DepCacheInfo[1] { (DepCacheInfo)(d_entries) };
|
||||
}
|
||||
else {
|
||||
depEntries = (CacheEntry[]) (d_entries);
|
||||
depEntries = (DepCacheInfo[])(d_entries);
|
||||
// verify that the object was fully constructed
|
||||
foreach (CacheEntry entry in depEntries) {
|
||||
foreach (DepCacheInfo entry in depEntries) {
|
||||
if (entry == null) {
|
||||
_bits[CHANGED] = true;
|
||||
// There is nothing to dispose because we haven't started
|
||||
@ -501,41 +502,32 @@ namespace System.Web.Caching {
|
||||
|
||||
// Monitor other cache entries for changes
|
||||
int lenMyEntries = depEntries.Length + cachekeys.Length;
|
||||
DateTime lastUpdated;
|
||||
if (lenMyEntries > 0 && !_bits[CHANGED]) {
|
||||
CacheEntry[] myEntries = new CacheEntry[lenMyEntries];
|
||||
DepCacheInfo[] myEntries = new DepCacheInfo[lenMyEntries];
|
||||
|
||||
// Monitor entries from the existing cache dependency
|
||||
int i = 0;
|
||||
foreach (CacheEntry entry in depEntries) {
|
||||
entry.AddCacheDependencyNotify(this);
|
||||
foreach (DepCacheInfo entry in depEntries) {
|
||||
entry._cacheStore.AddDependent(entry._key, this, out lastUpdated);
|
||||
myEntries[i++] = entry;
|
||||
}
|
||||
|
||||
// Monitor new entries specified for this depenedency
|
||||
// Entries must be added to cache, and created before the startTime
|
||||
cacheInternal = HttpRuntime.CacheInternal;
|
||||
cache = isPublic ? HttpRuntime.Cache.ObjectCache : HttpRuntime.Cache.InternalCache;
|
||||
foreach (string k in cachekeys) {
|
||||
CacheEntry entry = (CacheEntry) cacheInternal.DoGet(isPublic, k, CacheGetOptions.ReturnCacheEntry);
|
||||
if (entry != null) {
|
||||
entry.AddCacheDependencyNotify(this);
|
||||
myEntries[i++] = entry;
|
||||
if (cache.AddDependent(k, this, out lastUpdated)) {
|
||||
myEntries[i++] = new DepCacheInfo() { _cacheStore = cache, _key = k };
|
||||
|
||||
if (entry.UtcCreated > _utcLastModified) {
|
||||
_utcLastModified = entry.UtcCreated;
|
||||
if (lastUpdated > _utcLastModified) {
|
||||
_utcLastModified = lastUpdated;
|
||||
}
|
||||
|
||||
if ( entry.State != CacheEntry.EntryState.AddedToCache ||
|
||||
entry.UtcCreated > utcStart) {
|
||||
|
||||
if (lastUpdated > utcStart) { // Cache item has been updated since start, consider changed
|
||||
#if DBG
|
||||
if (entry.State != CacheEntry.EntryState.AddedToCache) {
|
||||
Debug.Trace("CacheDependencyInit", "Entry is not in cache, considered changed:" + k);
|
||||
}
|
||||
else {
|
||||
Debug.Trace("CacheDependencyInit", "Changes occurred to entry since start time:" + k);
|
||||
}
|
||||
Debug.Trace("CacheDependencyInit", "Changes occurred to entry since start time:" + k);
|
||||
#endif
|
||||
|
||||
_bits[CHANGED] = true;
|
||||
break;
|
||||
}
|
||||
@ -583,7 +575,7 @@ namespace System.Web.Caching {
|
||||
// Set this bit just in case our derived ctor forgot to call FinishInit()
|
||||
_bits[DERIVED_INIT] = true;
|
||||
|
||||
if (Use()) {
|
||||
if (TakeOwnership()) {
|
||||
// Do the dispose only if the cache has not already used us
|
||||
DisposeInternal();
|
||||
}
|
||||
@ -660,17 +652,17 @@ namespace System.Web.Caching {
|
||||
|
||||
// stop monitoring cache items
|
||||
if (l_entries != null) {
|
||||
CacheEntry oneEntry = l_entries as CacheEntry;
|
||||
DepCacheInfo oneEntry = l_entries as DepCacheInfo;
|
||||
if (oneEntry != null) {
|
||||
oneEntry.RemoveCacheDependencyNotify(this);
|
||||
oneEntry._cacheStore.RemoveDependent(oneEntry._key, this);
|
||||
}
|
||||
else {
|
||||
CacheEntry[] entries = (CacheEntry[]) l_entries;
|
||||
foreach (CacheEntry entry in entries) {
|
||||
DepCacheInfo[] entries = (DepCacheInfo[])l_entries;
|
||||
foreach (DepCacheInfo entry in entries) {
|
||||
// ensure that we handle partially contructed
|
||||
// objects by checking entry for null
|
||||
if (entry != null) {
|
||||
entry.RemoveCacheDependencyNotify(this);
|
||||
entry._cacheStore.RemoveDependent(entry._key, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -686,8 +678,10 @@ namespace System.Web.Caching {
|
||||
#endif
|
||||
}
|
||||
|
||||
// allow the first user to declare ownership
|
||||
internal bool Use() {
|
||||
/// <devdoc>
|
||||
/// <para>Allow the first user to declare exclusive ownership of this dependency.</para>
|
||||
/// </devdoc>
|
||||
public bool TakeOwnership() {
|
||||
return _bits.ChangeValue(USED, true);
|
||||
}
|
||||
|
||||
@ -706,22 +700,38 @@ namespace System.Web.Caching {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void SetUtcLastModified(DateTime utcLastModified) {
|
||||
_utcLastModified = utcLastModified;
|
||||
}
|
||||
|
||||
//
|
||||
// Add/remove an NotifyDependencyChanged notification.
|
||||
//
|
||||
internal void SetCacheDependencyChanged(ICacheDependencyChanged objNotify) {
|
||||
public void KeepDependenciesAlive() {
|
||||
if (_entries != null) {
|
||||
// update the last access time of every cache item that depends on this dependency
|
||||
DepCacheInfo oneEntry = _entries as DepCacheInfo;
|
||||
if (oneEntry != null) {
|
||||
oneEntry._cacheStore.Get(oneEntry._key);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (DepCacheInfo entry in (DepCacheInfo[])_entries) {
|
||||
if (entry != null) {
|
||||
object item = entry._cacheStore.Get(entry._key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <devdoc>
|
||||
/// <para>Add an Action to handle notifying interested party in changes to this dependency.</para>
|
||||
/// </devdoc>
|
||||
public void SetCacheDependencyChanged(Action<Object, EventArgs> dependencyChangedAction) {
|
||||
Debug.Assert(_objNotify == null, "_objNotify == null");
|
||||
|
||||
// Set this bit just in case our derived ctor forgot to call FinishInit()
|
||||
_bits[DERIVED_INIT] = true;
|
||||
|
||||
|
||||
if (!_bits[BASE_DISPOSED]) {
|
||||
_objNotify = objNotify;
|
||||
_objNotify = dependencyChangedAction;
|
||||
}
|
||||
}
|
||||
|
||||
@ -768,23 +778,23 @@ namespace System.Web.Caching {
|
||||
// get unique id from cache entries
|
||||
l_entries = _entries;
|
||||
if (l_entries != null) {
|
||||
CacheEntry oneEntry = l_entries as CacheEntry;
|
||||
DepCacheInfo oneEntry = l_entries as DepCacheInfo;
|
||||
if (oneEntry != null) {
|
||||
if (sb == null)
|
||||
sb = new StringBuilder();
|
||||
sb.Append(oneEntry.Key);
|
||||
sb.Append(oneEntry.UtcCreated.Ticks.ToString(CultureInfo.InvariantCulture));
|
||||
sb.Append(oneEntry._key);
|
||||
sb.Append(oneEntry.GetHashCode().ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
else {
|
||||
CacheEntry[] entries = (CacheEntry[]) l_entries;
|
||||
foreach (CacheEntry entry in entries) {
|
||||
DepCacheInfo[] entries = (DepCacheInfo[])l_entries;
|
||||
foreach (DepCacheInfo entry in entries) {
|
||||
// ensure that we handle partially contructed
|
||||
// objects by checking entry for null
|
||||
if (entry != null) {
|
||||
if (sb == null)
|
||||
sb = new StringBuilder();
|
||||
sb.Append(entry.Key);
|
||||
sb.Append(entry.UtcCreated.Ticks.ToString(CultureInfo.InvariantCulture));
|
||||
sb.Append(entry._key);
|
||||
sb.Append(entry.GetHashCode().ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -805,24 +815,6 @@ namespace System.Web.Caching {
|
||||
return _uniqueID;
|
||||
}
|
||||
|
||||
//
|
||||
// Return the cacheEntries monitored by this dependency
|
||||
//
|
||||
internal CacheEntry[] CacheEntries {
|
||||
get {
|
||||
if (_entries == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CacheEntry oneEntry = _entries as CacheEntry;
|
||||
if (oneEntry != null) {
|
||||
return new CacheEntry[1] {oneEntry};
|
||||
}
|
||||
|
||||
return (CacheEntry[]) _entries;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// This object has changed, so fire the NotifyDependencyChanged event.
|
||||
// We only allow this event to be fired once.
|
||||
@ -832,20 +824,20 @@ namespace System.Web.Caching {
|
||||
if (_bits.ChangeValue(CHANGED, true)) {
|
||||
_utcLastModified = DateTime.UtcNow;
|
||||
|
||||
ICacheDependencyChanged objNotify = _objNotify;
|
||||
if (objNotify != null && !_bits[BASE_DISPOSED]) {
|
||||
Action<Object, EventArgs> action = _objNotify as Action<Object, EventArgs>;
|
||||
if (action != null && !_bits[BASE_DISPOSED]) {
|
||||
Debug.Trace("CacheDependencyNotifyDependencyChanged", "change occurred");
|
||||
objNotify.DependencyChanged(sender, e);
|
||||
action(sender, e);
|
||||
}
|
||||
|
||||
DisposeInternal();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// ItemRemoved is called when a cache entry we are monitoring has been removed.
|
||||
//
|
||||
internal void ItemRemoved() {
|
||||
/// <devdoc>
|
||||
/// <para>ItemRemoved should be called when an ICacheEntry we are monitoring has been removed.</para>
|
||||
/// </devdoc>
|
||||
public void ItemRemoved() {
|
||||
NotifyDependencyChanged(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
@ -880,12 +872,12 @@ namespace System.Web.Caching {
|
||||
// Check and see if we are dependent on any cache entries
|
||||
l_entries = _entries;
|
||||
if (l_entries != null) {
|
||||
CacheEntry oneEntry = l_entries as CacheEntry;
|
||||
DepCacheInfo oneEntry = l_entries as DepCacheInfo;
|
||||
if (oneEntry != null) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
CacheEntry[] entries = (CacheEntry[]) l_entries;
|
||||
DepCacheInfo[] entries = (DepCacheInfo[]) l_entries;
|
||||
if (entries != null && entries.Length > 0) {
|
||||
return false;
|
||||
}
|
||||
@ -952,7 +944,7 @@ namespace System.Web.Caching {
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AggregateCacheDependency : CacheDependency, ICacheDependencyChanged {
|
||||
public sealed class AggregateCacheDependency : CacheDependency {
|
||||
ArrayList _dependencies;
|
||||
bool _disposed;
|
||||
|
||||
@ -979,10 +971,9 @@ namespace System.Web.Caching {
|
||||
throw new ArgumentNullException("dependencies");
|
||||
}
|
||||
|
||||
if (!d.Use()) {
|
||||
if (!d.TakeOwnership()) {
|
||||
throw new InvalidOperationException(SR.GetString(SR.Cache_dependency_used_more_that_once));
|
||||
}
|
||||
}
|
||||
} }
|
||||
|
||||
// add dependencies, and check if any have changed
|
||||
bool hasChanged = false;
|
||||
@ -995,7 +986,9 @@ namespace System.Web.Caching {
|
||||
_dependencies.AddRange(dependencies);
|
||||
|
||||
foreach (CacheDependency d in dependencies) {
|
||||
d.SetCacheDependencyChanged(this);
|
||||
d.SetCacheDependencyChanged((Object sender, EventArgs args) => {
|
||||
DependencyChanged(sender, args);
|
||||
});
|
||||
|
||||
if (d.UtcLastModified > utcLastModified) {
|
||||
utcLastModified = d.UtcLastModified;
|
||||
@ -1041,7 +1034,7 @@ namespace System.Web.Caching {
|
||||
// Forward call from the aggregate to the CacheEntry
|
||||
|
||||
/// <internalonly/>
|
||||
void ICacheDependencyChanged.DependencyChanged(Object sender, EventArgs e) {
|
||||
void DependencyChanged(Object sender, EventArgs e) {
|
||||
NotifyDependencyChanged(sender, e);
|
||||
}
|
||||
|
||||
@ -1122,7 +1115,7 @@ namespace System.Web.Caching {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This method will return only the file dependencies from this dependency
|
||||
/// </summary>
|
||||
|
@ -50,8 +50,8 @@ namespace System.Web.Caching {
|
||||
#endif
|
||||
}
|
||||
|
||||
internal String Key {
|
||||
get {return _key;}
|
||||
internal String Key {
|
||||
get { return _key; }
|
||||
}
|
||||
|
||||
internal bool IsOutputCache {
|
||||
@ -81,9 +81,7 @@ namespace System.Web.Caching {
|
||||
* An entry in the cache.
|
||||
* Overhead is 68 bytes + object header.
|
||||
*/
|
||||
internal sealed class CacheEntry : CacheKey, ICacheDependencyChanged {
|
||||
static readonly DateTime NoAbsoluteExpiration = DateTime.MaxValue;
|
||||
static readonly TimeSpan NoSlidingExpiration = TimeSpan.Zero;
|
||||
internal sealed class CacheEntry : CacheKey {
|
||||
const CacheItemPriority CacheItemPriorityMin = CacheItemPriority.Low;
|
||||
const CacheItemPriority CacheItemPriorityMax = CacheItemPriority.NotRemovable;
|
||||
static readonly TimeSpan OneYear = new TimeSpan(365, 0, 0, 0);
|
||||
@ -116,12 +114,13 @@ namespace System.Web.Caching {
|
||||
byte _usageBucket; /* index of the usage list (== priority-1) */
|
||||
UsageEntryRef _usageEntryRef; /* ref into the usage list */
|
||||
DateTime _utcLastUpdate; /* time we last updated usage */
|
||||
CacheInternal _cache;
|
||||
|
||||
// dependencies
|
||||
CacheDependency _dependency; /* dependencies this item has */
|
||||
object _onRemovedTargets; /* targets of OnRemove notification */
|
||||
|
||||
/*
|
||||
/*
|
||||
* ctor.
|
||||
*/
|
||||
|
||||
@ -130,10 +129,11 @@ namespace System.Web.Caching {
|
||||
Object value,
|
||||
CacheDependency dependency,
|
||||
CacheItemRemovedCallback onRemovedHandler,
|
||||
DateTime utcAbsoluteExpiration,
|
||||
DateTime utcAbsoluteExpiration,
|
||||
TimeSpan slidingExpiration,
|
||||
CacheItemPriority priority,
|
||||
bool isPublic) :
|
||||
bool isPublic,
|
||||
CacheInternal cache) :
|
||||
|
||||
base(key, isPublic) {
|
||||
|
||||
@ -176,6 +176,8 @@ namespace System.Web.Caching {
|
||||
else {
|
||||
_usageBucket = (byte) (priority - 1);
|
||||
}
|
||||
|
||||
_cache = cache;
|
||||
}
|
||||
|
||||
internal Object Value {
|
||||
@ -248,21 +250,23 @@ namespace System.Web.Caching {
|
||||
// need to protect against the item being closed
|
||||
CacheDependency dependency = _dependency;
|
||||
if (dependency != null && State == EntryState.AddedToCache) {
|
||||
if (!dependency.Use()) {
|
||||
if (!dependency.TakeOwnership()) {
|
||||
throw new InvalidOperationException(
|
||||
SR.GetString(SR.Cache_dependency_used_more_that_once));
|
||||
}
|
||||
|
||||
dependency.SetCacheDependencyChanged(this);
|
||||
dependency.SetCacheDependencyChanged((Object sender, EventArgs args) => {
|
||||
DependencyChanged(sender, args);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The entry has changed, so remove ourselves from the cache.
|
||||
*/
|
||||
void ICacheDependencyChanged.DependencyChanged(Object sender, EventArgs e) {
|
||||
void DependencyChanged(Object sender, EventArgs e) {
|
||||
if (State == EntryState.AddedToCache) {
|
||||
HttpRuntime.CacheInternal.Remove(this, CacheItemRemovedReason.DependencyChanged);
|
||||
_cache.Remove(this, CacheItemRemovedReason.DependencyChanged);
|
||||
}
|
||||
}
|
||||
|
||||
@ -369,7 +373,7 @@ namespace System.Web.Caching {
|
||||
}
|
||||
#endif
|
||||
|
||||
internal void AddCacheDependencyNotify(CacheDependency dependency) {
|
||||
internal void AddDependent(CacheDependency dependency) {
|
||||
lock (this) {
|
||||
if (_onRemovedTargets == null) {
|
||||
_onRemovedTargets = dependency;
|
||||
@ -387,16 +391,14 @@ namespace System.Web.Caching {
|
||||
}
|
||||
}
|
||||
|
||||
internal void RemoveCacheDependencyNotify(CacheDependency dependency) {
|
||||
internal void RemoveDependent(CacheDependency dependency) {
|
||||
lock (this) {
|
||||
if (_onRemovedTargets != null) {
|
||||
if (_onRemovedTargets == dependency) {
|
||||
_onRemovedTargets = null;
|
||||
}
|
||||
else {
|
||||
// We assume the dependency must exist, so we don't need
|
||||
// to test for a cast.
|
||||
Hashtable h = (Hashtable) _onRemovedTargets;
|
||||
else if (_onRemovedTargets is Hashtable) {
|
||||
Hashtable h = (Hashtable)_onRemovedTargets;
|
||||
h.Remove(dependency);
|
||||
if (h.Count == 0) {
|
||||
_onRemovedTargets = null;
|
||||
|
@ -282,29 +282,17 @@ namespace System.Web.Caching {
|
||||
|
||||
|
||||
//
|
||||
// helpers for accessing CacheInternal
|
||||
// helpers for accessing InternalCache
|
||||
//
|
||||
|
||||
// add CachedVary
|
||||
private static CachedVary UtcAdd(String key, CachedVary cachedVary) {
|
||||
return (CachedVary) HttpRuntime.CacheInternal.UtcAdd(key,
|
||||
cachedVary,
|
||||
null /*dependencies*/,
|
||||
Cache.NoAbsoluteExpiration,
|
||||
Cache.NoSlidingExpiration,
|
||||
CacheItemPriority.Normal,
|
||||
null /*callback*/);
|
||||
return (CachedVary) HttpRuntime.Cache.InternalCache.Add(key, cachedVary, null);
|
||||
}
|
||||
|
||||
// add ControlCachedVary
|
||||
private static ControlCachedVary UtcAdd(String key, ControlCachedVary cachedVary) {
|
||||
return (ControlCachedVary) HttpRuntime.CacheInternal.UtcAdd(key,
|
||||
cachedVary,
|
||||
null /*dependencies*/,
|
||||
Cache.NoAbsoluteExpiration,
|
||||
Cache.NoSlidingExpiration,
|
||||
CacheItemPriority.Normal,
|
||||
null /*callback*/);
|
||||
return (ControlCachedVary) HttpRuntime.Cache.InternalCache.Add(key, cachedVary, null);
|
||||
}
|
||||
|
||||
private static bool IsSubstBlockSerializable(HttpRawResponse rawResponse) {
|
||||
@ -391,7 +379,7 @@ namespace System.Web.Caching {
|
||||
String kernelCacheUrl = cachedRawResponse._kernelCacheUrl;
|
||||
// if it is kernel cached, the url will be non-null.
|
||||
// if the entry was re-inserted, don't remove kernel entry since it will be updated
|
||||
if (kernelCacheUrl != null && HttpRuntime.CacheInternal.Get(key) == null) {
|
||||
if (kernelCacheUrl != null && HttpRuntime.Cache.InternalCache.Get(key) == null) {
|
||||
// invalidate kernel cache entry
|
||||
if (HttpRuntime.UseIntegratedPipeline) {
|
||||
UnsafeIISMethods.MgdFlushKernelCache(kernelCacheUrl);
|
||||
@ -462,7 +450,7 @@ namespace System.Web.Caching {
|
||||
}
|
||||
|
||||
// is the file dependency already in the in-memory cache?
|
||||
if (HttpRuntime.CacheInternal.Get(depKey) != null) {
|
||||
if (HttpRuntime.Cache.InternalCache.Get(depKey) != null) {
|
||||
#if DBG
|
||||
Debug.Trace("OutputCache", "HasDependencyChanged(" + depKey + ", ..., " + oceKey + ", ...) --> false");
|
||||
#endif
|
||||
@ -480,9 +468,10 @@ namespace System.Web.Caching {
|
||||
// have the file dependencies changed?
|
||||
if (String.Compare(dep.GetUniqueID(), 0, depKey, idStartIndex, idLength, StringComparison.Ordinal) == 0) {
|
||||
// file dependencies have not changed--cache them with callback to remove OutputCacheEntry if they change
|
||||
HttpRuntime.CacheInternal.UtcInsert(depKey, new DependencyCacheEntry(oceKey, kernelKey, providerName), dep,
|
||||
Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration,
|
||||
CacheItemPriority.Normal, callback);
|
||||
HttpRuntime.Cache.InternalCache.Insert(depKey, new DependencyCacheEntry(oceKey, kernelKey, providerName), new CacheInsertOptions() {
|
||||
Dependencies = dep,
|
||||
OnRemovedCallback = callback
|
||||
});
|
||||
#if DBG
|
||||
Debug.Trace("OutputCache", "HasDependencyChanged(" + depKey + ", ..., " + oceKey + ", ...) --> false, DEPENDENCY RE-INSERTED");
|
||||
#endif
|
||||
@ -545,7 +534,7 @@ namespace System.Web.Caching {
|
||||
}
|
||||
}
|
||||
if (result == null) {
|
||||
result = HttpRuntime.CacheInternal.Get(key);
|
||||
result = HttpRuntime.Cache.InternalCache.Get(key);
|
||||
#if DBG
|
||||
string typeName = (result != null) ? result.GetType().Name : "null";
|
||||
Debug.Trace("OutputCache", "Get(" + key + ") --> " + typeName + ", CacheInternal");
|
||||
@ -580,7 +569,7 @@ namespace System.Web.Caching {
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
result = HttpRuntime.CacheInternal.Get(key);
|
||||
result = HttpRuntime.Cache.InternalCache.Get(key);
|
||||
#if DBG
|
||||
string typeName = (result != null) ? result.GetType().Name : "null";
|
||||
Debug.Trace("OutputCache", "GetFragment(" + key + "," + providerName + ") --> " + typeName + ", CacheInternal");
|
||||
@ -601,7 +590,7 @@ namespace System.Web.Caching {
|
||||
// If the context is null, then we don't know which
|
||||
// provider and we have to check all.
|
||||
|
||||
HttpRuntime.CacheInternal.Remove(key);
|
||||
HttpRuntime.Cache.InternalCache.Remove(key);
|
||||
|
||||
if (context == null) {
|
||||
// remove from all providers since we don't know which one it's in.
|
||||
@ -654,7 +643,7 @@ namespace System.Web.Caching {
|
||||
if (provider != null) {
|
||||
provider.Remove(key);
|
||||
}
|
||||
HttpRuntime.CacheInternal.Remove(key);
|
||||
HttpRuntime.Cache.InternalCache.Remove(key);
|
||||
#if DBG
|
||||
Debug.Trace("OutputCache", "RemoveFragment(" + key + "," + providerName + ")");
|
||||
#endif
|
||||
@ -708,7 +697,7 @@ namespace System.Web.Caching {
|
||||
if (!cachedVary.Equals(cachedVaryInCache)) {
|
||||
// overwrite existing cached vary
|
||||
if (!useProvider) {
|
||||
HttpRuntime.CacheInternal.UtcInsert(cachedVaryKey, cachedVary);
|
||||
HttpRuntime.Cache.InternalCache.Insert(cachedVaryKey, cachedVary, null);
|
||||
}
|
||||
else {
|
||||
provider.Set(cachedVaryKey, cachedVary, Cache.NoAbsoluteExpiration);
|
||||
@ -733,11 +722,11 @@ namespace System.Web.Caching {
|
||||
|
||||
// Now insert into the cache (use cache provider if possible, otherwise use internal cache)
|
||||
if (!useProvider) {
|
||||
HttpRuntime.CacheInternal.UtcInsert(fragmentKey, fragment,
|
||||
dependencies,
|
||||
absExp, slidingExp,
|
||||
CacheItemPriority.Normal,
|
||||
null);
|
||||
HttpRuntime.Cache.InternalCache.Insert(fragmentKey, fragment, new CacheInsertOptions() {
|
||||
Dependencies = dependencies,
|
||||
AbsoluteExpiration = absExp,
|
||||
SlidingExpiration = slidingExp
|
||||
});
|
||||
}
|
||||
else {
|
||||
string depKey = null;
|
||||
@ -749,10 +738,12 @@ namespace System.Web.Caching {
|
||||
provider.Set(fragmentKey, fragment, absExp);
|
||||
if (dependencies != null) {
|
||||
// use Add and dispose dependencies if there's already one in the cache
|
||||
Object d = HttpRuntime.CacheInternal.UtcAdd(depKey, new DependencyCacheEntry(fragmentKey, null, provider.Name),
|
||||
dependencies,
|
||||
absExp, Cache.NoSlidingExpiration,
|
||||
CacheItemPriority.Normal, s_dependencyRemovedCallbackForFragment);
|
||||
Object d = HttpRuntime.Cache.InternalCache.Add(depKey, new DependencyCacheEntry(fragmentKey, null, provider.Name),
|
||||
new CacheInsertOptions() {
|
||||
Dependencies = dependencies,
|
||||
AbsoluteExpiration = absExp,
|
||||
OnRemovedCallback = s_dependencyRemovedCallbackForFragment
|
||||
});
|
||||
if (d != null) {
|
||||
dependencies.Dispose();
|
||||
}
|
||||
@ -768,7 +759,7 @@ namespace System.Web.Caching {
|
||||
+ fragmentKey + ", PartialCachingCacheEntry, ...) -->"
|
||||
+ providerUsed);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// insert cached vary or output cache entry
|
||||
internal static void InsertResponse(String cachedVaryKey, CachedVary cachedVary,
|
||||
@ -820,7 +811,7 @@ namespace System.Web.Caching {
|
||||
if (cachedVaryInCache != null) {
|
||||
if (!cachedVary.Equals(cachedVaryInCache)) {
|
||||
if (!useProvider) {
|
||||
HttpRuntime.CacheInternal.UtcInsert(cachedVaryKey, cachedVary);
|
||||
HttpRuntime.Cache.InternalCache.Insert(cachedVaryKey, cachedVary, null);
|
||||
}
|
||||
else {
|
||||
provider.Set(cachedVaryKey, cachedVary, Cache.NoAbsoluteExpiration);
|
||||
@ -845,11 +836,12 @@ namespace System.Web.Caching {
|
||||
|
||||
// Now insert into the cache (use cache provider if possible, otherwise use internal cache)
|
||||
if (!useProvider) {
|
||||
HttpRuntime.CacheInternal.UtcInsert(rawResponseKey, rawResponse,
|
||||
dependencies,
|
||||
absExp, slidingExp,
|
||||
CacheItemPriority.Normal,
|
||||
s_entryRemovedCallback);
|
||||
HttpRuntime.Cache.InternalCache.Insert(rawResponseKey, rawResponse, new CacheInsertOptions() {
|
||||
Dependencies = dependencies,
|
||||
AbsoluteExpiration = absExp,
|
||||
SlidingExpiration = slidingExp,
|
||||
OnRemovedCallback = s_entryRemovedCallback
|
||||
});
|
||||
|
||||
IncrementCount();
|
||||
|
||||
@ -867,10 +859,12 @@ namespace System.Web.Caching {
|
||||
provider.Set(rawResponseKey, oce, absExp);
|
||||
if (dependencies != null) {
|
||||
// use Add and dispose dependencies if there's already one in the cache
|
||||
Object d = HttpRuntime.CacheInternal.UtcAdd(depKey, new DependencyCacheEntry(rawResponseKey, oce.KernelCacheUrl, provider.Name),
|
||||
dependencies,
|
||||
absExp, Cache.NoSlidingExpiration,
|
||||
CacheItemPriority.Normal, s_dependencyRemovedCallback);
|
||||
Object d = HttpRuntime.Cache.InternalCache.Add(depKey, new DependencyCacheEntry(rawResponseKey, oce.KernelCacheUrl, provider.Name),
|
||||
new CacheInsertOptions() {
|
||||
Dependencies = dependencies,
|
||||
AbsoluteExpiration = absExp,
|
||||
OnRemovedCallback = s_dependencyRemovedCallbackForFragment
|
||||
});
|
||||
if (d != null) {
|
||||
dependencies.Dispose();
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ namespace System.Web.Caching {
|
||||
{
|
||||
Debug.Trace("SqlCacheDependency",
|
||||
"Depend on key=" + GetDependKey(databaseEntryName, tableName) + "; value=" +
|
||||
HttpRuntime.CacheInternal[GetDependKey(databaseEntryName, tableName)]);
|
||||
HttpRuntime.Cache.InternalCache.Get(GetDependKey(databaseEntryName, tableName)));
|
||||
|
||||
// Permission checking is done in GetDependKey()
|
||||
|
||||
@ -77,7 +77,7 @@ namespace System.Web.Caching {
|
||||
_sql7DepInfo._database = databaseEntryName;
|
||||
_sql7DepInfo._table = tableName;
|
||||
|
||||
object o = HttpRuntime.CacheInternal[GetDependKey(databaseEntryName, tableName)];
|
||||
object o = HttpRuntime.Cache.InternalCache.Get(GetDependKey(databaseEntryName, tableName));
|
||||
if (o == null) {
|
||||
// If the cache entry can't be found, this cache dependency will be set to CHANGED already.
|
||||
_sql7ChangeId = -1;
|
||||
@ -756,7 +756,7 @@ namespace System.Web.Caching {
|
||||
SqlCommand sqlCmd = null;
|
||||
int changeId;
|
||||
string tableName;
|
||||
CacheInternal cacheInternal = HttpRuntime.CacheInternal;
|
||||
CacheStoreProvider cacheInternal = HttpRuntime.Cache.InternalCache;
|
||||
string monitorKey;
|
||||
object obj;
|
||||
bool notifEnabled = false;
|
||||
@ -864,33 +864,28 @@ namespace System.Web.Caching {
|
||||
"Database=" + dbState._database+ "; tableName=" + tableName + "; changeId=" + changeId);
|
||||
|
||||
monitorKey = GetMoniterKey(dbState._database, tableName);
|
||||
obj = cacheInternal[monitorKey];
|
||||
obj = cacheInternal.Get(monitorKey);
|
||||
|
||||
if (obj == null) {
|
||||
Debug.Assert(!dbState._tables.ContainsKey(tableName),
|
||||
"DatabaseNotifStae._tables and internal cache keys should be in-[....]");
|
||||
"DatabaseNotifStae._tables and internal cache keys should be in-sync");
|
||||
|
||||
Debug.Trace("SqlCacheDependencyManagerPolling",
|
||||
"Add Database=" + dbState._database+ "; tableName=" + tableName + "; changeId=" + changeId);
|
||||
|
||||
cacheInternal.UtcAdd(monitorKey, changeId, null,
|
||||
Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration,
|
||||
CacheItemPriority.NotRemovable, null);
|
||||
|
||||
cacheInternal.Add(monitorKey, changeId, new CacheInsertOptions() { Priority = CacheItemPriority.NotRemovable });
|
||||
dbState._tables.Add(tableName, null);
|
||||
}
|
||||
else if (changeId != (int)obj) {
|
||||
Debug.Assert(dbState._tables.ContainsKey(tableName),
|
||||
"DatabaseNotifStae._tables and internal cache keys should be in-[....]");
|
||||
"DatabaseNotifStae._tables and internal cache keys should be in-sync");
|
||||
|
||||
Debug.Trace("SqlCacheDependencyManagerPolling",
|
||||
"Change Database=" + dbState._database+ "; tableName=" + tableName + "; old=" + (int)obj + "; new=" + changeId);
|
||||
|
||||
// ChangeId is different. It means some table changes have happened.
|
||||
// Update local cache value
|
||||
cacheInternal.UtcInsert(monitorKey, changeId, null,
|
||||
Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration,
|
||||
CacheItemPriority.NotRemovable, null);
|
||||
cacheInternal.Insert(monitorKey, changeId, new CacheInsertOptions() { Priority = CacheItemPriority.NotRemovable });
|
||||
}
|
||||
|
||||
originalTables.Remove(tableName);
|
||||
@ -1001,8 +996,8 @@ namespace System.Web.Caching {
|
||||
// for this table has successfully completed
|
||||
Debug.Trace("SqlCacheDependencyManagerCheck",
|
||||
"Check is called. Database=" + database+ "; table=" + table);
|
||||
|
||||
if (HttpRuntime.CacheInternal[GetMoniterKey(database, table)] != null) {
|
||||
|
||||
if (HttpRuntime.Cache.InternalCache.Get(GetMoniterKey(database, table)) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user