Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 5 / 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
- ToolBarButtonClickEvent.cs
- ParseChildrenAsPropertiesAttribute.cs
- CommonObjectSecurity.cs
- CmsInterop.cs
- NestedContainer.cs
- ExpandCollapseProviderWrapper.cs
- StandardBindingElement.cs
- FixedDocumentSequencePaginator.cs
- SelectionHighlightInfo.cs
- CheckBoxRenderer.cs
- CodeDomSerializerBase.cs
- SecurityImpersonationBehavior.cs
- SelectingProviderEventArgs.cs
- Helper.cs
- BitmapSizeOptions.cs
- XmlSchemaParticle.cs
- FigureParaClient.cs
- FrameworkTextComposition.cs
- WebBaseEventKeyComparer.cs
- UnauthorizedWebPart.cs
- WebConfigurationHost.cs
- BamlResourceSerializer.cs
- SystemIPInterfaceStatistics.cs
- UpdateProgress.cs
- ItemsControl.cs
- SocketPermission.cs
- TextEndOfSegment.cs
- SecurityHeaderTokenResolver.cs
- TabRenderer.cs
- Crc32Helper.cs
- EnumBuilder.cs
- PolyBezierSegmentFigureLogic.cs
- RoleBoolean.cs
- SchemaTableOptionalColumn.cs
- Button.cs
- Icon.cs
- SqlPersonalizationProvider.cs
- FactorySettingsElement.cs
- FilterElement.cs
- StreamResourceInfo.cs
- SiteMapDesignerDataSourceView.cs
- SqlDataSourceStatusEventArgs.cs
- RangeContentEnumerator.cs
- NativeMethods.cs
- FontConverter.cs
- TextClipboardData.cs
- HttpCacheParams.cs
- XmlDictionaryReaderQuotas.cs
- DataGridViewHitTestInfo.cs
- ConsoleTraceListener.cs
- SeparatorAutomationPeer.cs
- Line.cs
- Image.cs
- SerializationHelper.cs
- ComplexPropertyEntry.cs
- ImageInfo.cs
- EntityContainer.cs
- PasswordDeriveBytes.cs
- VirtualDirectoryMapping.cs
- SimplePropertyEntry.cs
- DurationConverter.cs
- PageStatePersister.cs
- BufferedWebEventProvider.cs
- DesignTimeTemplateParser.cs
- XmlDataSourceView.cs
- DataGridViewBand.cs
- ConnectionInterfaceCollection.cs
- LayoutEngine.cs
- BinaryEditor.cs
- SmtpReplyReaderFactory.cs
- FilterQuery.cs
- DeclarationUpdate.cs
- DynamicVirtualDiscoSearcher.cs
- MenuAdapter.cs
- FixedSOMContainer.cs
- CompilationRelaxations.cs
- HtmlForm.cs
- RequestCachePolicy.cs
- ExitEventArgs.cs
- Propagator.JoinPropagator.cs
- XPathAncestorIterator.cs
- KeyValueConfigurationElement.cs
- DataGridViewSelectedRowCollection.cs
- Merger.cs
- DeviceSpecificChoiceCollection.cs
- ZipIOExtraFieldPaddingElement.cs
- PointLightBase.cs
- SqlDataSource.cs
- CaseInsensitiveHashCodeProvider.cs
- QueueException.cs
- UnitySerializationHolder.cs
- DefaultObjectMappingItemCollection.cs
- FeatureSupport.cs
- EntityDataSourceWrapperPropertyDescriptor.cs
- HandlerBase.cs
- SocketPermission.cs
- XmlSchemaAttribute.cs
- DateTimeOffset.cs
- UnmanagedMemoryStream.cs
- ComplexType.cs