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
- PageVisual.cs
- DataGridViewDataErrorEventArgs.cs
- CurrentChangingEventManager.cs
- MemoryMappedFileSecurity.cs
- BitmapMetadata.cs
- ObjectSecurityT.cs
- FixedSchema.cs
- ObjectStateEntry.cs
- DesignerVerb.cs
- Rect3DValueSerializer.cs
- TagMapInfo.cs
- WorkflowInstanceQuery.cs
- XmlSchemaAll.cs
- WindowsListViewScroll.cs
- TableLayoutSettingsTypeConverter.cs
- DrawingCollection.cs
- WebRequestModulesSection.cs
- TextTabProperties.cs
- XPathQueryGenerator.cs
- MatrixCamera.cs
- UnsupportedPolicyOptionsException.cs
- HtmlEmptyTagControlBuilder.cs
- WebScriptServiceHost.cs
- ConfigurationStrings.cs
- ValidationError.cs
- PreloadedPackages.cs
- FileLoadException.cs
- FixedTextBuilder.cs
- ZipIORawDataFileBlock.cs
- SiteMapHierarchicalDataSourceView.cs
- XmlSchemaType.cs
- RectConverter.cs
- ReadOnlyDictionary.cs
- ChangeTracker.cs
- ResXResourceWriter.cs
- ZoneIdentityPermission.cs
- FigureHelper.cs
- UniformGrid.cs
- ComNativeDescriptor.cs
- Label.cs
- PolygonHotSpot.cs
- WebBrowserBase.cs
- CompilerCollection.cs
- TimeEnumHelper.cs
- ToolboxComponentsCreatedEventArgs.cs
- HyperLinkColumn.cs
- ErrorsHelper.cs
- HttpModuleAction.cs
- ColorTransform.cs
- rsa.cs
- wgx_exports.cs
- SqlDataReaderSmi.cs
- SatelliteContractVersionAttribute.cs
- PropagatorResult.cs
- ToolboxService.cs
- DescendantBaseQuery.cs
- ButtonRenderer.cs
- SelectionEditingBehavior.cs
- ClientSettingsProvider.cs
- SystemDiagnosticsSection.cs
- AdjustableArrowCap.cs
- SolidColorBrush.cs
- RegexCompiler.cs
- FlowDocumentPage.cs
- TraceUtility.cs
- PersonalizablePropertyEntry.cs
- XmlTypeMapping.cs
- ButtonField.cs
- RemoteWebConfigurationHost.cs
- SamlSecurityTokenAuthenticator.cs
- GetIndexBinder.cs
- WorkflowMarkupSerializationManager.cs
- ListComponentEditor.cs
- FocusWithinProperty.cs
- SqlCacheDependency.cs
- SqlProviderManifest.cs
- MetadataItemCollectionFactory.cs
- ZipPackage.cs
- TextEndOfParagraph.cs
- WebReferencesBuildProvider.cs
- ToolboxItemCollection.cs
- CodeCastExpression.cs
- AutomationPropertyInfo.cs
- AutomationProperty.cs
- GlyphTypeface.cs
- DocumentXmlWriter.cs
- nulltextnavigator.cs
- MainMenu.cs
- FunctionCommandText.cs
- PlanCompiler.cs
- FunctionUpdateCommand.cs
- PortCache.cs
- CompressionTracing.cs
- WindowsImpersonationContext.cs
- ThemeableAttribute.cs
- MediaContext.cs
- TransformerInfo.cs
- Signature.cs
- TagNameToTypeMapper.cs
- XmlText.cs