Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 3 / 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;
}
}
}
}
}
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CodeGotoStatement.cs
- CustomActivityDesigner.cs
- TextProviderWrapper.cs
- OracleException.cs
- DoubleCollection.cs
- UIElement3DAutomationPeer.cs
- ZipIOLocalFileHeader.cs
- InfoCardTraceRecord.cs
- TaiwanCalendar.cs
- DropTarget.cs
- SyncOperationState.cs
- ComEventsHelper.cs
- XmlMapping.cs
- HandleCollector.cs
- TableLayoutRowStyleCollection.cs
- TypeBrowserDialog.cs
- ExtendedProperty.cs
- ToolConsole.cs
- SchemaType.cs
- DataSourceControlBuilder.cs
- SqlDataSourceQueryConverter.cs
- SmiRequestExecutor.cs
- DateTimeConverter.cs
- ObjectDataSourceView.cs
- DispatcherSynchronizationContext.cs
- DashStyle.cs
- UnionCodeGroup.cs
- ScrollViewerAutomationPeer.cs
- ConfigurationElement.cs
- GeneralTransform3D.cs
- Attributes.cs
- XPathScanner.cs
- BitmapEffectDrawingContent.cs
- AppModelKnownContentFactory.cs
- ResourceProperty.cs
- TimeEnumHelper.cs
- DataBindingHandlerAttribute.cs
- Filter.cs
- HtmlTableRow.cs
- StoreItemCollection.cs
- Error.cs
- LowerCaseStringConverter.cs
- ObjectComplexPropertyMapping.cs
- JsonSerializer.cs
- EventPropertyMap.cs
- SplineKeyFrames.cs
- ContextMenuService.cs
- CodeIdentifiers.cs
- PersistenceMetadataNamespace.cs
- RegisteredArrayDeclaration.cs
- PrintPreviewDialog.cs
- SystemException.cs
- DesignerDataColumn.cs
- SerTrace.cs
- WSHttpSecurity.cs
- ArgumentOutOfRangeException.cs
- WindowsToolbarItemAsMenuItem.cs
- DeflateEmulationStream.cs
- Trigger.cs
- AtomPub10CategoriesDocumentFormatter.cs
- LogicalChannel.cs
- StateWorkerRequest.cs
- WebServiceHandler.cs
- QueryRelOp.cs
- CharAnimationBase.cs
- RayMeshGeometry3DHitTestResult.cs
- OpenTypeCommon.cs
- TdsParserSessionPool.cs
- AspNetHostingPermission.cs
- PartitionedStream.cs
- ToolStripLabel.cs
- RequestCacheManager.cs
- StateElement.cs
- DBConcurrencyException.cs
- CorrelationTokenInvalidatedHandler.cs
- NavigationPropertyEmitter.cs
- BrowsableAttribute.cs
- TabControlAutomationPeer.cs
- CommandDesigner.cs
- WebRequestModuleElementCollection.cs
- ProfilePropertySettings.cs
- CharUnicodeInfo.cs
- JoinTreeSlot.cs
- UrlAuthFailedErrorFormatter.cs
- HttpCapabilitiesSectionHandler.cs
- WindowsToolbar.cs
- DataRecordInternal.cs
- Rotation3DAnimationBase.cs
- HierarchicalDataBoundControlAdapter.cs
- SystemDropShadowChrome.cs
- OracleConnectionString.cs
- ItemList.cs
- cookiecollection.cs
- AttributeCollection.cs
- DataGridTableCollection.cs
- LineVisual.cs
- Pointer.cs
- ByteStream.cs
- WindowsComboBox.cs
- HtmlInputPassword.cs