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
- XPathScanner.cs
- MouseActionValueSerializer.cs
- DrawingVisualDrawingContext.cs
- CompilationRelaxations.cs
- MemberInfoSerializationHolder.cs
- MemberInfoSerializationHolder.cs
- BufferedOutputStream.cs
- DbMetaDataColumnNames.cs
- CTreeGenerator.cs
- XamlPoint3DCollectionSerializer.cs
- AsnEncodedData.cs
- NotifyCollectionChangedEventArgs.cs
- DataGridCellClipboardEventArgs.cs
- AutoGeneratedFieldProperties.cs
- DocumentScope.cs
- EventProxy.cs
- HtmlTableRowCollection.cs
- ModelVisual3D.cs
- SecuritySessionFilter.cs
- DataGridRowEventArgs.cs
- IriParsingElement.cs
- ClockController.cs
- DataServicePagingProviderWrapper.cs
- MemoryFailPoint.cs
- XmlSerializableReader.cs
- InfoCardCryptoHelper.cs
- DrawingContextWalker.cs
- MobileDeviceCapabilitiesSectionHandler.cs
- InfoCardSymmetricAlgorithm.cs
- HashCodeCombiner.cs
- DBDataPermissionAttribute.cs
- TransformerConfigurationWizardBase.cs
- CompatibleComparer.cs
- ZeroOpNode.cs
- ReadingWritingEntityEventArgs.cs
- DiscoveryDocument.cs
- DeclarativeCatalogPart.cs
- RemoteWebConfigurationHost.cs
- ApplicationFileCodeDomTreeGenerator.cs
- Brushes.cs
- GridViewAutomationPeer.cs
- XPathNode.cs
- ListViewUpdateEventArgs.cs
- FastPropertyAccessor.cs
- ConfigDefinitionUpdates.cs
- StringUtil.cs
- TextDpi.cs
- ImageAttributes.cs
- CodeNamespace.cs
- UnsafeNativeMethodsPenimc.cs
- ViewManager.cs
- CounterSet.cs
- Rect3DValueSerializer.cs
- ResourcePermissionBaseEntry.cs
- PrivateFontCollection.cs
- FormView.cs
- TcpClientChannel.cs
- BitmapPalette.cs
- SystemIcmpV6Statistics.cs
- ListViewUpdateEventArgs.cs
- DesignOnlyAttribute.cs
- externdll.cs
- CompiledAction.cs
- SqlProviderServices.cs
- designeractionlistschangedeventargs.cs
- NativeMethods.cs
- invalidudtexception.cs
- Camera.cs
- Color.cs
- CatalogPartCollection.cs
- MatchingStyle.cs
- EncodingDataItem.cs
- WebPartMovingEventArgs.cs
- SqlBuffer.cs
- PrinterUnitConvert.cs
- CFStream.cs
- StructuredTypeEmitter.cs
- ListViewCancelEventArgs.cs
- SafeSecurityHelper.cs
- EntityContainerEmitter.cs
- AdCreatedEventArgs.cs
- InvalidPrinterException.cs
- DataRecordInternal.cs
- ScriptManagerProxy.cs
- VectorKeyFrameCollection.cs
- StrongNameIdentityPermission.cs
- ListViewUpdatedEventArgs.cs
- HyperLinkColumn.cs
- XmlNavigatorFilter.cs
- Soap.cs
- SimpleTypesSurrogate.cs
- XhtmlBasicValidationSummaryAdapter.cs
- TypeResolver.cs
- GenericParameterDataContract.cs
- SuppressMergeCheckAttribute.cs
- GatewayDefinition.cs
- SHA512.cs
- LogWriteRestartAreaAsyncResult.cs
- HierarchicalDataTemplate.cs
- Stack.cs