Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 5 / 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
- LabelInfo.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- XmlCharacterData.cs
- AppDomainAttributes.cs
- EncoderNLS.cs
- DATA_BLOB.cs
- AssemblyNameProxy.cs
- PolyQuadraticBezierSegment.cs
- SafeRightsManagementPubHandle.cs
- LookupNode.cs
- PathBox.cs
- ExpressionBinding.cs
- LineProperties.cs
- ZipIOExtraField.cs
- BoundPropertyEntry.cs
- ToolStripDropDownMenu.cs
- querybuilder.cs
- Walker.cs
- AgileSafeNativeMemoryHandle.cs
- DataService.cs
- ToolStripComboBox.cs
- ListenerConnectionDemuxer.cs
- ZoneLinkButton.cs
- HttpCachePolicy.cs
- DataFormats.cs
- Menu.cs
- ProgramNode.cs
- RegisteredDisposeScript.cs
- BitHelper.cs
- PropertyRecord.cs
- TrackingMemoryStream.cs
- OleDbStruct.cs
- ProjectedSlot.cs
- WebPartDisplayModeCollection.cs
- HyperLinkColumn.cs
- PropertyGridView.cs
- UIElementCollection.cs
- x509utils.cs
- cookie.cs
- CodeCompileUnit.cs
- FixedPage.cs
- HtmlTable.cs
- GenericsNotImplementedException.cs
- MimeObjectFactory.cs
- SchemaAttDef.cs
- TreeViewHitTestInfo.cs
- XmlSchemaAny.cs
- SubMenuStyleCollection.cs
- WrapPanel.cs
- BamlRecordReader.cs
- SettingsProviderCollection.cs
- FeedUtils.cs
- DependencyPropertyKey.cs
- StateFinalizationDesigner.cs
- SpeechAudioFormatInfo.cs
- RuleSetBrowserDialog.cs
- CompositeFontParser.cs
- TrustManagerPromptUI.cs
- SharedPersonalizationStateInfo.cs
- ErrorRuntimeConfig.cs
- Hashtable.cs
- ButtonField.cs
- AsyncOperationManager.cs
- WebRequest.cs
- UTF32Encoding.cs
- MsmqBindingFilter.cs
- SocketInformation.cs
- EventMappingSettingsCollection.cs
- AdapterDictionary.cs
- Stackframe.cs
- TableSectionStyle.cs
- PriorityBinding.cs
- WsiProfilesElementCollection.cs
- WebConfigurationHost.cs
- HttpDictionary.cs
- HtmlInputImage.cs
- DataBindingCollectionConverter.cs
- SQLInt32Storage.cs
- BufferedGraphicsContext.cs
- EntityProviderServices.cs
- DiagnosticsConfiguration.cs
- ErrorHandler.cs
- CodeComment.cs
- DataControlField.cs
- OdbcCommandBuilder.cs
- SecUtil.cs
- UserControl.cs
- WhileDesigner.cs
- TransactionsSectionGroup.cs
- LabelDesigner.cs
- ErrorsHelper.cs
- PropertyValueUIItem.cs
- Merger.cs
- MimeFormReflector.cs
- SqlNode.cs
- TableCell.cs
- HotSpotCollectionEditor.cs
- PropertyGridEditorPart.cs
- _ContextAwareResult.cs
- WebServiceHandlerFactory.cs