Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- AvTraceDetails.cs
- StylusEventArgs.cs
- ImageKeyConverter.cs
- BooleanSwitch.cs
- ProfileModule.cs
- SqlInternalConnectionTds.cs
- CompositionTarget.cs
- CharEntityEncoderFallback.cs
- DataListAutoFormat.cs
- PerfCounters.cs
- WebHttpBindingElement.cs
- MimeWriter.cs
- SortAction.cs
- Border.cs
- AudioFormatConverter.cs
- AttributeCollection.cs
- UInt32Storage.cs
- RoutingChannelExtension.cs
- MaskedTextBox.cs
- PropertyValueChangedEvent.cs
- InfoCardClaimCollection.cs
- MasterPageCodeDomTreeGenerator.cs
- HostedTransportConfigurationBase.cs
- CreateParams.cs
- ProviderUtil.cs
- Parameter.cs
- BindingMAnagerBase.cs
- QueryInterceptorAttribute.cs
- Renderer.cs
- SubMenuStyleCollection.cs
- XmlSignificantWhitespace.cs
- ByteStorage.cs
- ObjectReaderCompiler.cs
- DependencyPropertyDescriptor.cs
- AuthenticationConfig.cs
- ExeConfigurationFileMap.cs
- Comparer.cs
- PropertyChange.cs
- LoginView.cs
- DoubleLink.cs
- ObjectReaderCompiler.cs
- RelatedImageListAttribute.cs
- BaseTemplateCodeDomTreeGenerator.cs
- HttpHandlersInstallComponent.cs
- ServiceHttpModule.cs
- TemplateKey.cs
- TraceHwndHost.cs
- KerberosRequestorSecurityTokenAuthenticator.cs
- UncommonField.cs
- Attributes.cs
- SqlDataSourceCache.cs
- TreeNodeCollection.cs
- httpapplicationstate.cs
- InstanceStore.cs
- Vector3D.cs
- DesignerObject.cs
- DataPagerField.cs
- VisualBasicSettings.cs
- XmlWriterTraceListener.cs
- Vector3DAnimationBase.cs
- XPathNavigator.cs
- ClientBuildManager.cs
- QuaternionRotation3D.cs
- Process.cs
- oledbconnectionstring.cs
- ButtonStandardAdapter.cs
- PolicyFactory.cs
- DependencyPropertyDescriptor.cs
- AvTraceDetails.cs
- TextEditorTyping.cs
- WindowsListViewGroupHelper.cs
- CalendarButton.cs
- SetterTriggerConditionValueConverter.cs
- DropDownButton.cs
- MultiView.cs
- SQLMoneyStorage.cs
- ProfessionalColors.cs
- XmlSchemaImport.cs
- CheckBox.cs
- EmbeddedMailObjectsCollection.cs
- BooleanAnimationBase.cs
- FormatterServices.cs
- StrokeCollectionConverter.cs
- AutomationPeer.cs
- DataSysAttribute.cs
- BamlRecordWriter.cs
- EmissiveMaterial.cs
- SdlChannelSink.cs
- LogLogRecordHeader.cs
- TextFormatterHost.cs
- UnsafeNativeMethods.cs
- UpDownBase.cs
- PassportAuthenticationModule.cs
- CLSCompliantAttribute.cs
- GroupStyle.cs
- HtmlTable.cs
- DirectoryNotFoundException.cs
- ClientCredentialsElement.cs
- Region.cs
- CheckBoxRenderer.cs