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
- HtmlEmptyTagControlBuilder.cs
- StatusBarAutomationPeer.cs
- StylusPoint.cs
- RegexNode.cs
- ComponentSerializationService.cs
- LocalsItemDescription.cs
- odbcmetadatacollectionnames.cs
- FrameworkElement.cs
- DataGridViewColumnEventArgs.cs
- ExpandSegmentCollection.cs
- HttpModuleAction.cs
- SqlInfoMessageEvent.cs
- OutputScope.cs
- ListViewGroupItemCollection.cs
- DataBoundControlAdapter.cs
- XmlSchemaAny.cs
- HttpInputStream.cs
- BoundPropertyEntry.cs
- SHA512.cs
- StylusCollection.cs
- TargetParameterCountException.cs
- TreeNodeEventArgs.cs
- login.cs
- RelationshipManager.cs
- ListBindableAttribute.cs
- DirectoryObjectSecurity.cs
- StreamGeometry.cs
- CharAnimationUsingKeyFrames.cs
- PixelFormatConverter.cs
- CoreSwitches.cs
- datacache.cs
- TraceSection.cs
- Win32SafeHandles.cs
- XmlLinkedNode.cs
- RuntimeCompatibilityAttribute.cs
- SingleObjectCollection.cs
- MenuItem.cs
- ZipIOLocalFileBlock.cs
- SoundPlayer.cs
- _PooledStream.cs
- NotificationContext.cs
- BitmapEffectInput.cs
- TextBox.cs
- WebConfigurationManager.cs
- AuthorizationRule.cs
- StrokeNodeEnumerator.cs
- ScalarConstant.cs
- BehaviorEditorPart.cs
- PersonalizationState.cs
- CodeTypeReferenceCollection.cs
- Nullable.cs
- NavigateUrlConverter.cs
- DocumentGridContextMenu.cs
- SchemaContext.cs
- GridViewCancelEditEventArgs.cs
- SolidBrush.cs
- TextTreeNode.cs
- EnterpriseServicesHelper.cs
- IntegerFacetDescriptionElement.cs
- HttpInputStream.cs
- SerializationObjectManager.cs
- PingOptions.cs
- FormViewUpdateEventArgs.cs
- XamlBrushSerializer.cs
- LayoutExceptionEventArgs.cs
- DependencyPropertyKind.cs
- LinkedList.cs
- DataGridCellsPanel.cs
- SecUtil.cs
- FileLevelControlBuilderAttribute.cs
- HttpRequestCacheValidator.cs
- SrgsToken.cs
- EventListenerClientSide.cs
- XmlEventCache.cs
- XPathMessageFilterElementCollection.cs
- ModelService.cs
- MasterPageCodeDomTreeGenerator.cs
- HttpWebRequest.cs
- DocumentApplicationJournalEntry.cs
- ProgramPublisher.cs
- AccessorTable.cs
- XmlILTrace.cs
- EventItfInfo.cs
- InvalidWMPVersionException.cs
- CheckBoxAutomationPeer.cs
- Transform3D.cs
- AffineTransform3D.cs
- ClrProviderManifest.cs
- TemplateKeyConverter.cs
- SkinBuilder.cs
- LocatorPart.cs
- CssClassPropertyAttribute.cs
- COM2Properties.cs
- IsolatedStoragePermission.cs
- SiteMap.cs
- WorkflowElementDialogWindow.xaml.cs
- StringConcat.cs
- FreezableCollection.cs
- RedistVersionInfo.cs
- AppSettingsExpressionBuilder.cs