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
- ClientBuildManager.cs
- RegexMatchCollection.cs
- ConvertTextFrag.cs
- Win32MouseDevice.cs
- assemblycache.cs
- DbConnectionPoolGroup.cs
- TextElementCollectionHelper.cs
- BamlRecordHelper.cs
- TextSelectionProcessor.cs
- PrivilegeNotHeldException.cs
- StreamResourceInfo.cs
- webclient.cs
- DefaultAssemblyResolver.cs
- TextDataBindingHandler.cs
- SplitterPanel.cs
- TextTreeTextNode.cs
- externdll.cs
- Source.cs
- WizardForm.cs
- DescendantBaseQuery.cs
- CurrencyWrapper.cs
- VariableReference.cs
- SqlInternalConnectionSmi.cs
- DataSourceCacheDurationConverter.cs
- FixedSOMTable.cs
- PersonalizationState.cs
- ConfigXmlText.cs
- FileSystemWatcher.cs
- StringConverter.cs
- SoapSchemaMember.cs
- PlaceHolder.cs
- ContentTextAutomationPeer.cs
- CodeRegionDirective.cs
- _BaseOverlappedAsyncResult.cs
- HostedHttpContext.cs
- ReadOnlyCollectionBuilder.cs
- XmlNodeList.cs
- SpecialNameAttribute.cs
- SourceFileBuildProvider.cs
- QuarticEase.cs
- RowToParametersTransformer.cs
- DebugInfo.cs
- COM2Enum.cs
- IItemContainerGenerator.cs
- SplitterCancelEvent.cs
- RIPEMD160.cs
- AppDomainManager.cs
- VisualTreeFlattener.cs
- ClientProxyGenerator.cs
- PrefixQName.cs
- PermissionListSet.cs
- RemoteWebConfigurationHostServer.cs
- EmptyStringExpandableObjectConverter.cs
- DataErrorValidationRule.cs
- AspNetSynchronizationContext.cs
- ShaperBuffers.cs
- EntryIndex.cs
- TextChange.cs
- OleDbInfoMessageEvent.cs
- StreamGeometryContext.cs
- PointAnimation.cs
- ToolStripRenderEventArgs.cs
- TextFormatterContext.cs
- DesignerDataConnection.cs
- PersistenceTypeAttribute.cs
- StatusBarDrawItemEvent.cs
- Rect3DConverter.cs
- Barrier.cs
- COSERVERINFO.cs
- WebControlAdapter.cs
- _FixedSizeReader.cs
- NetWebProxyFinder.cs
- Sql8ExpressionRewriter.cs
- TrackingValidationObjectDictionary.cs
- RectAnimationClockResource.cs
- ComboBoxAutomationPeer.cs
- DataTablePropertyDescriptor.cs
- PerformanceCountersElement.cs
- GraphicsContainer.cs
- WebPartVerb.cs
- HyperlinkAutomationPeer.cs
- ProtocolElementCollection.cs
- StoreItemCollection.cs
- NullReferenceException.cs
- PrimitiveXmlSerializers.cs
- ToolStripStatusLabel.cs
- FontUnit.cs
- SafeViewOfFileHandle.cs
- DataObjectCopyingEventArgs.cs
- EnterpriseServicesHelper.cs
- FileDetails.cs
- ControlOperationBehavior.cs
- SequentialUshortCollection.cs
- QilStrConcat.cs
- Queue.cs
- COSERVERINFO.cs
- TreeViewImageIndexConverter.cs
- ZipIORawDataFileBlock.cs
- StatusBar.cs
- ItemDragEvent.cs