Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 1305376 / SimpleRecyclingCache.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
* SimpleRecyclingCache class
*
* Copyright (c) 1999 Microsoft Corporation
*/
namespace System.Web.Util {
using System.Collections;
/*
* The purpose of this class is to provide a simple and efficient cache.
* Instead of using fancy logic to expire items, it uses a simple heuristic:
* when the number of entry reaches a fixed limit, the cache is reset.
*/
internal class SimpleRecyclingCache {
private const int MAX_SIZE = 100;
private static Hashtable _hashtable;
internal SimpleRecyclingCache() {
CreateHashtable();
}
// Create or recreate the hastable
private void CreateHashtable() {
_hashtable = new Hashtable(MAX_SIZE, StringComparer.OrdinalIgnoreCase);
}
internal object this[object key] {
get {
return _hashtable[key];
}
set {
lock (this) {
// The limit was reached, so reset everything
if (_hashtable.Count >= MAX_SIZE)
_hashtable.Clear();
_hashtable[key] = value;
}
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
* SimpleRecyclingCache class
*
* Copyright (c) 1999 Microsoft Corporation
*/
namespace System.Web.Util {
using System.Collections;
/*
* The purpose of this class is to provide a simple and efficient cache.
* Instead of using fancy logic to expire items, it uses a simple heuristic:
* when the number of entry reaches a fixed limit, the cache is reset.
*/
internal class SimpleRecyclingCache {
private const int MAX_SIZE = 100;
private static Hashtable _hashtable;
internal SimpleRecyclingCache() {
CreateHashtable();
}
// Create or recreate the hastable
private void CreateHashtable() {
_hashtable = new Hashtable(MAX_SIZE, StringComparer.OrdinalIgnoreCase);
}
internal object this[object key] {
get {
return _hashtable[key];
}
set {
lock (this) {
// The limit was reached, so reset everything
if (_hashtable.Count >= MAX_SIZE)
_hashtable.Clear();
_hashtable[key] = value;
}
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CustomError.cs
- AssociativeAggregationOperator.cs
- XmlWhitespace.cs
- ObjRef.cs
- Control.cs
- TypeConverterValueSerializer.cs
- SafeCryptoHandles.cs
- NativeMethods.cs
- AssociatedControlConverter.cs
- AxHost.cs
- FillBehavior.cs
- Query.cs
- Bold.cs
- Transform3D.cs
- SchemaElement.cs
- ListBindableAttribute.cs
- XmlNodeChangedEventArgs.cs
- InputGestureCollection.cs
- SoapHeaders.cs
- ViewGenResults.cs
- DataBindingCollectionEditor.cs
- DbProviderSpecificTypePropertyAttribute.cs
- XmlnsCache.cs
- SettingsPropertyIsReadOnlyException.cs
- HttpCachePolicyBase.cs
- Util.cs
- XsdBuildProvider.cs
- DockPanel.cs
- InlineObject.cs
- FunctionGenerator.cs
- IndexingContentUnit.cs
- DataGridViewComponentPropertyGridSite.cs
- UrlMappingsSection.cs
- Verify.cs
- OleDbFactory.cs
- PropertyChangingEventArgs.cs
- TransformPattern.cs
- SqlInternalConnectionTds.cs
- ConnectionPool.cs
- SqlClientMetaDataCollectionNames.cs
- ConstructorNeedsTagAttribute.cs
- Rotation3D.cs
- HeaderUtility.cs
- WebDisplayNameAttribute.cs
- KnownTypeDataContractResolver.cs
- MultiSelector.cs
- SelectedCellsCollection.cs
- COM2Properties.cs
- AuthenticationModulesSection.cs
- BigInt.cs
- AspNetSynchronizationContext.cs
- TabControlAutomationPeer.cs
- PerSessionInstanceContextProvider.cs
- DrawingAttributesDefaultValueFactory.cs
- MsmqProcessProtocolHandler.cs
- UIElementParaClient.cs
- Evaluator.cs
- XPathConvert.cs
- HttpCachePolicyElement.cs
- PersonalizationStateInfoCollection.cs
- FieldTemplateFactory.cs
- DebuggerAttributes.cs
- Inline.cs
- OleDbPropertySetGuid.cs
- LocalsItemDescription.cs
- ArraySortHelper.cs
- COSERVERINFO.cs
- SafeNativeMethods.cs
- DataGridViewCellValidatingEventArgs.cs
- SoapClientMessage.cs
- SQLResource.cs
- SqlEnums.cs
- SqlTopReducer.cs
- ClientUrlResolverWrapper.cs
- WebWorkflowRole.cs
- MultiView.cs
- DateTimeOffset.cs
- VoiceSynthesis.cs
- DependencyPropertyChangedEventArgs.cs
- UInt16Converter.cs
- WindowCollection.cs
- CodeIdentifiers.cs
- RoutedEventConverter.cs
- SoapServerMethod.cs
- ConnectionProviderAttribute.cs
- XPathDocumentIterator.cs
- SiteMembershipCondition.cs
- SqlUtils.cs
- ProcessModuleCollection.cs
- DisplayMemberTemplateSelector.cs
- RijndaelManaged.cs
- BamlTreeNode.cs
- AssemblySettingAttributes.cs
- PeerTransportBindingElement.cs
- DbLambda.cs
- ItemPager.cs
- MultipartContentParser.cs
- XmlReturnWriter.cs
- Adorner.cs
- DefaultProxySection.cs