Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 3 / 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; } } } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CopyOnWriteList.cs
- FactoryGenerator.cs
- HttpConfigurationSystem.cs
- VsPropertyGrid.cs
- HtmlForm.cs
- SizeF.cs
- DefaultDialogButtons.cs
- DispatcherExceptionEventArgs.cs
- MailMessageEventArgs.cs
- AppDomainAttributes.cs
- TypeDelegator.cs
- EnvironmentPermission.cs
- DbConnectionPool.cs
- TransformProviderWrapper.cs
- ListenerElementsCollection.cs
- ColorConvertedBitmap.cs
- CounterCreationData.cs
- FeatureSupport.cs
- WorkflowNamespace.cs
- OnOperation.cs
- InheritanceContextHelper.cs
- Stroke2.cs
- LocatorManager.cs
- MachineKeyConverter.cs
- SmtpTransport.cs
- BuildManager.cs
- StringAnimationBase.cs
- BooleanKeyFrameCollection.cs
- ping.cs
- SafeReversePInvokeHandle.cs
- DataGridTextBox.cs
- NativeRightsManagementAPIsStructures.cs
- RegisteredHiddenField.cs
- PerspectiveCamera.cs
- ColumnClickEvent.cs
- StatusBarPanel.cs
- CodeTypeReference.cs
- XmlUtil.cs
- XmlSerializationWriter.cs
- QueryStringParameter.cs
- InplaceBitmapMetadataWriter.cs
- COAUTHIDENTITY.cs
- SimpleTextLine.cs
- SizeAnimation.cs
- GiveFeedbackEvent.cs
- DbConnectionStringCommon.cs
- DataServiceResponse.cs
- SingleResultAttribute.cs
- DelegateCompletionCallbackWrapper.cs
- DesigntimeLicenseContextSerializer.cs
- FolderLevelBuildProviderAppliesToAttribute.cs
- UInt16Storage.cs
- HttpListener.cs
- XmlAttributeProperties.cs
- RegexMatch.cs
- Point3DCollectionConverter.cs
- AggregateNode.cs
- VirtualPath.cs
- NestedContainer.cs
- EntryIndex.cs
- ResXResourceWriter.cs
- PostBackOptions.cs
- sqlstateclientmanager.cs
- OracleRowUpdatedEventArgs.cs
- MeshGeometry3D.cs
- IndexedString.cs
- ConfigXmlElement.cs
- ObjectKeyFrameCollection.cs
- TileBrush.cs
- XmlNodeChangedEventArgs.cs
- DbMetaDataColumnNames.cs
- ServiceControllerDesigner.cs
- RepeaterItem.cs
- GraphicsPathIterator.cs
- SettingsProperty.cs
- WebRequestModuleElement.cs
- Variable.cs
- CommandPlan.cs
- FrameAutomationPeer.cs
- LogManagementAsyncResult.cs
- SizeAnimationUsingKeyFrames.cs
- DrawingContextWalker.cs
- PairComparer.cs
- MsmqOutputMessage.cs
- OleDbConnection.cs
- XmlMemberMapping.cs
- ObfuscationAttribute.cs
- CookieProtection.cs
- PropertyItemInternal.cs
- Formatter.cs
- XComponentModel.cs
- DesignerDataTable.cs
- BuildProviderAppliesToAttribute.cs
- PasswordBoxAutomationPeer.cs
- TaskDesigner.cs
- ColorTransform.cs
- DesignerDeviceConfig.cs
- FieldValue.cs
- SignatureHelper.cs
- InvalidProgramException.cs