Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 1305376 / 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
- UserNameSecurityTokenProvider.cs
- SplitterCancelEvent.cs
- DynamicResourceExtensionConverter.cs
- FixedSOMTable.cs
- CharEnumerator.cs
- ValidatingPropertiesEventArgs.cs
- DataRecordInternal.cs
- AnimationTimeline.cs
- ReflectPropertyDescriptor.cs
- RegisterInfo.cs
- SmtpClient.cs
- HotSpot.cs
- ValidationSummary.cs
- PKCS1MaskGenerationMethod.cs
- WindowHideOrCloseTracker.cs
- SqlLiftWhereClauses.cs
- TextSpanModifier.cs
- UpdatePanelTrigger.cs
- IndentedWriter.cs
- Slider.cs
- ListViewGroupItemCollection.cs
- StringFormat.cs
- X509Certificate.cs
- DataGridViewRowHeaderCell.cs
- ParserContext.cs
- PeerCollaboration.cs
- ExpanderAutomationPeer.cs
- FormatStringEditor.cs
- PrintingPermissionAttribute.cs
- LoadGrammarCompletedEventArgs.cs
- CfgRule.cs
- IsolatedStorageException.cs
- OleDbErrorCollection.cs
- ContentPropertyAttribute.cs
- PresentationSource.cs
- PolyLineSegment.cs
- RtfFormatStack.cs
- OperationCanceledException.cs
- EventBindingService.cs
- XmlElement.cs
- rsa.cs
- SendSecurityHeaderElementContainer.cs
- ListViewUpdateEventArgs.cs
- FontDriver.cs
- HMACSHA384.cs
- GradientSpreadMethodValidation.cs
- StateBag.cs
- ControlEvent.cs
- LayoutInformation.cs
- StickyNoteHelper.cs
- EllipticalNodeOperations.cs
- AccessedThroughPropertyAttribute.cs
- HostingEnvironment.cs
- TreeView.cs
- CultureSpecificCharacterBufferRange.cs
- ModuleBuilder.cs
- TextPattern.cs
- SQLGuidStorage.cs
- Unit.cs
- ToolbarAUtomationPeer.cs
- SqlDataSource.cs
- RenderDataDrawingContext.cs
- SafeHandles.cs
- PageThemeCodeDomTreeGenerator.cs
- NavigationProperty.cs
- QilStrConcatenator.cs
- BinaryObjectInfo.cs
- EpmSourcePathSegment.cs
- RbTree.cs
- ChangeBlockUndoRecord.cs
- BuilderInfo.cs
- XPathNavigator.cs
- WorkflowMarkupElementEventArgs.cs
- EdmItemCollection.cs
- EasingKeyFrames.cs
- JoinSymbol.cs
- ArgumentNullException.cs
- ScriptMethodAttribute.cs
- TransformCollection.cs
- CatalogPartCollection.cs
- IDictionary.cs
- AsyncPostBackErrorEventArgs.cs
- CompositeActivityCodeGenerator.cs
- DataException.cs
- dtdvalidator.cs
- ProfileManager.cs
- ServiceDeploymentInfo.cs
- LayoutEvent.cs
- BrowserCapabilitiesFactory.cs
- filewebrequest.cs
- TemplateBuilder.cs
- BaseCAMarshaler.cs
- FormatterConverter.cs
- AssemblyResourceLoader.cs
- DispatcherHookEventArgs.cs
- Activation.cs
- CapabilitiesRule.cs
- FormViewRow.cs
- PageContent.cs
- XsdBuildProvider.cs