Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 1 / 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
- QueryResults.cs
- _SecureChannel.cs
- SecUtil.cs
- ShaderEffect.cs
- EUCJPEncoding.cs
- ColorAnimationBase.cs
- GridViewDeletedEventArgs.cs
- BamlResourceSerializer.cs
- XmlTextReaderImpl.cs
- IRCollection.cs
- _LocalDataStore.cs
- DataSourceCache.cs
- SymbolType.cs
- TaskResultSetter.cs
- OpacityConverter.cs
- DispatcherTimer.cs
- SubqueryRules.cs
- SqlUdtInfo.cs
- Condition.cs
- AppDomainProtocolHandler.cs
- MediaEntryAttribute.cs
- FormViewInsertEventArgs.cs
- JsonFormatWriterGenerator.cs
- odbcmetadatafactory.cs
- SourceChangedEventArgs.cs
- ExtenderControl.cs
- DeploymentSection.cs
- AssemblyCache.cs
- Shape.cs
- SqlInternalConnectionTds.cs
- RtfControls.cs
- XmlEncoding.cs
- DrawingGroupDrawingContext.cs
- PropertyCollection.cs
- TrustSection.cs
- AdornerPresentationContext.cs
- Lookup.cs
- DataGridViewCellCancelEventArgs.cs
- basecomparevalidator.cs
- RoutedEventConverter.cs
- PackagePartCollection.cs
- ComplexPropertyEntry.cs
- BufferedStream.cs
- SpecularMaterial.cs
- DesignRelationCollection.cs
- SystemIcons.cs
- XmlReaderDelegator.cs
- TimersDescriptionAttribute.cs
- AQNBuilder.cs
- DCSafeHandle.cs
- SyndicationSerializer.cs
- UnknownWrapper.cs
- TypeExtension.cs
- StyleModeStack.cs
- InvalidDataException.cs
- PeerApplicationLaunchInfo.cs
- WindowInteropHelper.cs
- WmpBitmapEncoder.cs
- MetadataArtifactLoaderResource.cs
- BufferBuilder.cs
- NewArray.cs
- Image.cs
- VirtualDirectoryMappingCollection.cs
- ApplicationServiceManager.cs
- RepeatBehaviorConverter.cs
- BufferedStream.cs
- OrderPreservingMergeHelper.cs
- KeyboardDevice.cs
- CreateUserErrorEventArgs.cs
- ZipIOLocalFileDataDescriptor.cs
- Input.cs
- CodeExporter.cs
- Properties.cs
- SafeTokenHandle.cs
- TextBoxBase.cs
- SmiEventSink_Default.cs
- SafeFindHandle.cs
- XmlText.cs
- DomNameTable.cs
- SharedPerformanceCounter.cs
- SizeChangedInfo.cs
- GeneralTransform3DCollection.cs
- MatrixStack.cs
- AmbiguousMatchException.cs
- Stylesheet.cs
- DoubleAnimationClockResource.cs
- Part.cs
- ProfilePropertyNameValidator.cs
- StreamWriter.cs
- ToolStripControlHost.cs
- DirectoryRootQuery.cs
- ArcSegment.cs
- ValueConversionAttribute.cs
- Rijndael.cs
- AsyncStreamReader.cs
- VisualTreeUtils.cs
- EntitySqlException.cs
- HttpCachePolicyElement.cs
- SchemaDeclBase.cs
- AllMembershipCondition.cs