Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 1 / 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
- OptimalTextSource.cs
- AsyncSerializedWorker.cs
- HttpModuleAction.cs
- BooleanToVisibilityConverter.cs
- ConstNode.cs
- InputReport.cs
- CodeGeneratorOptions.cs
- TagPrefixCollection.cs
- EventMemberCodeDomSerializer.cs
- OleAutBinder.cs
- DetailsViewPagerRow.cs
- DecoratedNameAttribute.cs
- ObservableCollectionDefaultValueFactory.cs
- IndicFontClient.cs
- _IPv6Address.cs
- Scalars.cs
- DesignerCategoryAttribute.cs
- StringConverter.cs
- PackageStore.cs
- ExtensionWindow.cs
- EntityContainerAssociationSetEnd.cs
- FragmentQueryKB.cs
- WindowsSlider.cs
- WebPartsPersonalizationAuthorization.cs
- TextEncodedRawTextWriter.cs
- PerfCounterSection.cs
- ValueCollectionParameterReader.cs
- DataGridViewCellParsingEventArgs.cs
- Viewport3DVisual.cs
- DependencyPropertyConverter.cs
- ActivityTypeCodeDomSerializer.cs
- URLAttribute.cs
- StrokeNodeOperations2.cs
- DetailsViewDeleteEventArgs.cs
- RangeValuePattern.cs
- TypeNameConverter.cs
- MediaElementAutomationPeer.cs
- DateTimeConstantAttribute.cs
- DispatcherObject.cs
- SqlDataSourceQueryConverter.cs
- ByteKeyFrameCollection.cs
- TextTreeRootNode.cs
- XmlException.cs
- ThreadPool.cs
- ComplexBindingPropertiesAttribute.cs
- HttpContextServiceHost.cs
- ImportCatalogPart.cs
- basenumberconverter.cs
- DataGridTableCollection.cs
- configsystem.cs
- ConfigurationValues.cs
- _ProxyChain.cs
- TheQuery.cs
- InitializationEventAttribute.cs
- TypeTypeConverter.cs
- AuthorizationRuleCollection.cs
- SpellerError.cs
- WebPartEventArgs.cs
- EmptyControlCollection.cs
- ThicknessConverter.cs
- TdsParser.cs
- CompilerParameters.cs
- ClientRuntimeConfig.cs
- ProgressBarAutomationPeer.cs
- OrderByQueryOptionExpression.cs
- ArrayWithOffset.cs
- CompoundFileReference.cs
- DynamicDocumentPaginator.cs
- RequestCachePolicyConverter.cs
- HotSpot.cs
- ExpressionLink.cs
- WpfPayload.cs
- __FastResourceComparer.cs
- AuthenticationModulesSection.cs
- TextPatternIdentifiers.cs
- ScriptingWebServicesSectionGroup.cs
- EncryptedType.cs
- UnsafeNativeMethods.cs
- HTMLTextWriter.cs
- CaseExpr.cs
- GcHandle.cs
- CellParaClient.cs
- AccessDataSourceView.cs
- InvokeFunc.cs
- TypeHelper.cs
- HTMLTextWriter.cs
- BlockCollection.cs
- Expression.cs
- ProcessProtocolHandler.cs
- ColorMap.cs
- BindingValueChangedEventArgs.cs
- GroupItem.cs
- SecurityMode.cs
- Matrix3DStack.cs
- ResolvePPIDRequest.cs
- TextWriterTraceListener.cs
- Vector3DCollection.cs
- HistoryEventArgs.cs
- ArraySubsetEnumerator.cs
- ToolStripItemEventArgs.cs