Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 4 / 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. //------------------------------------------------------------------------------ //// 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlArrayItemAttributes.cs
- EditingCommands.cs
- JoinElimination.cs
- MethodBuilderInstantiation.cs
- CookieParameter.cs
- TextView.cs
- ListChunk.cs
- LinearGradientBrush.cs
- Material.cs
- EntityKeyElement.cs
- InProcStateClientManager.cs
- Base64Stream.cs
- UriExt.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- OpacityConverter.cs
- PropertyItemInternal.cs
- ParentUndoUnit.cs
- HyperlinkAutomationPeer.cs
- DSACryptoServiceProvider.cs
- categoryentry.cs
- HandledEventArgs.cs
- TokenizerHelper.cs
- NegatedCellConstant.cs
- TextFormatterHost.cs
- TemporaryBitmapFile.cs
- LowerCaseStringConverter.cs
- RepeaterCommandEventArgs.cs
- Column.cs
- DoubleAnimationUsingPath.cs
- HttpWebRequest.cs
- UniqueIdentifierService.cs
- Membership.cs
- HtmlWindowCollection.cs
- Rectangle.cs
- ConnectionsZone.cs
- Common.cs
- DescendantQuery.cs
- HtmlShimManager.cs
- TextWriterTraceListener.cs
- UdpConstants.cs
- VectorValueSerializer.cs
- X509SecurityToken.cs
- SortQuery.cs
- AutomationElementCollection.cs
- BaseUriHelper.cs
- VisualBrush.cs
- DataGridViewSelectedCellCollection.cs
- TextRenderer.cs
- FeatureManager.cs
- Vector3DIndependentAnimationStorage.cs
- CallbackHandler.cs
- EmptyControlCollection.cs
- CatalogZoneDesigner.cs
- OleDbPropertySetGuid.cs
- IsolationInterop.cs
- BooleanSwitch.cs
- DynamicPropertyReader.cs
- SoapFormatter.cs
- SolidBrush.cs
- DefaultObjectMappingItemCollection.cs
- ProtectedConfigurationSection.cs
- BuildProvider.cs
- ViewLoader.cs
- DecimalConverter.cs
- TrackingServices.cs
- KeyMatchBuilder.cs
- ControlAdapter.cs
- StreamWithDictionary.cs
- DataGridViewRow.cs
- CollectionChangeEventArgs.cs
- webclient.cs
- WebPartDisplayModeCancelEventArgs.cs
- DataViewListener.cs
- Attributes.cs
- WCFBuildProvider.cs
- PrintController.cs
- SplitterPanelDesigner.cs
- ComponentSerializationService.cs
- AvTrace.cs
- SemanticAnalyzer.cs
- TileModeValidation.cs
- LayoutEvent.cs
- HyperLinkDesigner.cs
- DataTemplate.cs
- AppDomainGrammarProxy.cs
- PackageRelationshipCollection.cs
- DesignTimeHTMLTextWriter.cs
- PeerResolverBindingElement.cs
- RemoteWebConfigurationHost.cs
- PositiveTimeSpanValidator.cs
- TextParagraphView.cs
- MILUtilities.cs
- SpotLight.cs
- LicenseProviderAttribute.cs
- ElementInit.cs
- BoundField.cs
- DataTransferEventArgs.cs
- NativeMethods.cs
- RoutedUICommand.cs
- FontResourceCache.cs