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
- IdentityNotMappedException.cs
- ManagementNamedValueCollection.cs
- PageVisual.cs
- ContainerVisual.cs
- GeometryHitTestParameters.cs
- Maps.cs
- XmlSchemas.cs
- PageParserFilter.cs
- PeerContact.cs
- ListBoxItemWrapperAutomationPeer.cs
- WindowsFormsLinkLabel.cs
- PageSetupDialog.cs
- LinearKeyFrames.cs
- GenericIdentity.cs
- OleDbParameterCollection.cs
- Clipboard.cs
- BinaryNode.cs
- DecoderFallback.cs
- ButtonBase.cs
- BinHexEncoder.cs
- ExclusiveCanonicalizationTransform.cs
- Camera.cs
- EntityKey.cs
- UIntPtr.cs
- DataContractFormatAttribute.cs
- XmlDataLoader.cs
- ListComponentEditorPage.cs
- TranslateTransform3D.cs
- CreateUserWizard.cs
- DataGridViewButtonColumn.cs
- Deserializer.cs
- IisTraceListener.cs
- DbConnectionPoolOptions.cs
- MachineKeyConverter.cs
- DomNameTable.cs
- WaitHandle.cs
- FixedSOMImage.cs
- NestPullup.cs
- FilterableData.cs
- XmlAggregates.cs
- PointAnimationClockResource.cs
- AsymmetricSignatureDeformatter.cs
- Pens.cs
- DataServiceException.cs
- IntSecurity.cs
- LazyTextWriterCreator.cs
- BlurEffect.cs
- ProtocolsConfigurationEntry.cs
- TimelineGroup.cs
- Descriptor.cs
- RepeaterItemEventArgs.cs
- OutputCacheEntry.cs
- VisualStateManager.cs
- Registration.cs
- PasswordTextNavigator.cs
- InternalConfirm.cs
- TimeSpanOrInfiniteConverter.cs
- ConfigXmlElement.cs
- GridView.cs
- ObjectViewFactory.cs
- OdbcErrorCollection.cs
- DataTableTypeConverter.cs
- WebPartDeleteVerb.cs
- ProxyGenerationError.cs
- objectresult_tresulttype.cs
- WindowsSlider.cs
- PackWebRequestFactory.cs
- VisualStyleRenderer.cs
- _ContextAwareResult.cs
- SettingsSavedEventArgs.cs
- SkewTransform.cs
- TableLayoutPanel.cs
- ShaderEffect.cs
- MetaTable.cs
- DbMetaDataColumnNames.cs
- SpecialNameAttribute.cs
- ImageUrlEditor.cs
- ADMembershipUser.cs
- DataTransferEventArgs.cs
- WindowsStatic.cs
- DecoderBestFitFallback.cs
- DTCTransactionManager.cs
- VScrollBar.cs
- XmlKeywords.cs
- ConnectionManager.cs
- TreeWalkHelper.cs
- CellParagraph.cs
- XamlToRtfParser.cs
- Border.cs
- FixedTextView.cs
- TextBoxRenderer.cs
- TextBoxBase.cs
- BuildManager.cs
- DropDownList.cs
- MultiAsyncResult.cs
- SwitchElementsCollection.cs
- ApplicationTrust.cs
- WebBrowsableAttribute.cs
- unitconverter.cs
- UnicastIPAddressInformationCollection.cs