Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 5 / 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
- TcpSocketManager.cs
- DynamicDocumentPaginator.cs
- Label.cs
- SourceSwitch.cs
- UserNameSecurityTokenProvider.cs
- EntityCollectionChangedParams.cs
- FontEmbeddingManager.cs
- FixedStringLookup.cs
- MouseActionValueSerializer.cs
- TdsParserSafeHandles.cs
- PersistChildrenAttribute.cs
- DefaultTextStore.cs
- DefaultAssemblyResolver.cs
- altserialization.cs
- MimeMapping.cs
- Rule.cs
- ToolboxComponentsCreatingEventArgs.cs
- Nodes.cs
- DependencyPropertyKind.cs
- ProbeDuplexCD1AsyncResult.cs
- AttributeConverter.cs
- SymmetricAlgorithm.cs
- GraphicsContext.cs
- TextSelectionHelper.cs
- DocumentAutomationPeer.cs
- ListViewItem.cs
- DropAnimation.xaml.cs
- CustomError.cs
- InkPresenterAutomationPeer.cs
- TextTreeFixupNode.cs
- ProviderCollection.cs
- AnnotationService.cs
- GenerateScriptTypeAttribute.cs
- Typography.cs
- OptimalBreakSession.cs
- FileDialogCustomPlacesCollection.cs
- StrongTypingException.cs
- BaseTemplateParser.cs
- BamlMapTable.cs
- ExpressionBuilder.cs
- ProjectionPathBuilder.cs
- GcHandle.cs
- XmlLangPropertyAttribute.cs
- NominalTypeEliminator.cs
- ProtocolsConfigurationEntry.cs
- FunctionImportMapping.cs
- _TLSstream.cs
- ContractHandle.cs
- AccessViolationException.cs
- MemberHolder.cs
- GeneralTransform3DTo2D.cs
- PriorityBindingExpression.cs
- DesignOnlyAttribute.cs
- BitmapCacheBrush.cs
- NavigationService.cs
- ColorConvertedBitmapExtension.cs
- AudioLevelUpdatedEventArgs.cs
- XmlSchemaObject.cs
- SupportingTokenChannel.cs
- ZoneIdentityPermission.cs
- EventWaitHandle.cs
- TextBoxBase.cs
- MetadataCache.cs
- XmlTextReaderImpl.cs
- HtmlTableRowCollection.cs
- ToolboxItemFilterAttribute.cs
- ProfilePropertySettingsCollection.cs
- ProcessHostConfigUtils.cs
- ScriptDescriptor.cs
- TraceLevelStore.cs
- SymLanguageType.cs
- SessionStateModule.cs
- SqlClientWrapperSmiStreamChars.cs
- TextEffect.cs
- _HTTPDateParse.cs
- TableProviderWrapper.cs
- GridPatternIdentifiers.cs
- SqlSupersetValidator.cs
- StateBag.cs
- XamlWrappingReader.cs
- JsonCollectionDataContract.cs
- AccessibleObject.cs
- ArgumentOutOfRangeException.cs
- Highlights.cs
- TagPrefixAttribute.cs
- HyperLink.cs
- DropSource.cs
- TrustLevel.cs
- WeakRefEnumerator.cs
- Hash.cs
- DiscoveryServerProtocol.cs
- OwnerDrawPropertyBag.cs
- ConstNode.cs
- WarningException.cs
- Selector.cs
- HandlerWithFactory.cs
- XmlTextEncoder.cs
- GroupStyle.cs
- MediaPlayer.cs
- DefaultValueAttribute.cs