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
- PathNode.cs
- odbcmetadatacolumnnames.cs
- DateTimeUtil.cs
- ContentOperations.cs
- TextRangeBase.cs
- TextTreePropertyUndoUnit.cs
- ImageButton.cs
- WinFormsSpinner.cs
- XamlTemplateSerializer.cs
- PropertyRef.cs
- InkSerializer.cs
- SortableBindingList.cs
- EditorAttribute.cs
- FormView.cs
- EntitySetDataBindingList.cs
- SerializationException.cs
- CodeStatement.cs
- ComPlusServiceHost.cs
- RouteItem.cs
- SystemIPInterfaceProperties.cs
- Native.cs
- OdbcEnvironment.cs
- ListBindingConverter.cs
- RegexWorker.cs
- DynamicPropertyHolder.cs
- ItemContainerPattern.cs
- SQLByte.cs
- InstancePersistenceCommand.cs
- Section.cs
- ValidatorCollection.cs
- CroppedBitmap.cs
- ObjectListShowCommandsEventArgs.cs
- Typography.cs
- ThreadExceptionEvent.cs
- FocusManager.cs
- FlowLayoutSettings.cs
- DetailsViewRowCollection.cs
- RTLAwareMessageBox.cs
- LogFlushAsyncResult.cs
- RSAPKCS1KeyExchangeFormatter.cs
- _ScatterGatherBuffers.cs
- ModuleConfigurationInfo.cs
- XmlSchemaAll.cs
- XmlParserContext.cs
- NativeMethods.cs
- RuntimeHandles.cs
- PermissionSetEnumerator.cs
- LineProperties.cs
- UpdateProgress.cs
- DetailsView.cs
- ClockGroup.cs
- WriteLineDesigner.xaml.cs
- HwndSource.cs
- StateChangeEvent.cs
- AssemblyResolver.cs
- AnnouncementInnerClientCD1.cs
- EmptyQuery.cs
- TraceUtility.cs
- ConstraintEnumerator.cs
- DropShadowEffect.cs
- HtmlLabelAdapter.cs
- TemplateModeChangedEventArgs.cs
- TextElementEditingBehaviorAttribute.cs
- QilTernary.cs
- FilterableAttribute.cs
- ViewManager.cs
- TailCallAnalyzer.cs
- ConcurrentBag.cs
- IgnoreSectionHandler.cs
- COM2PictureConverter.cs
- Decorator.cs
- ShapeTypeface.cs
- _AuthenticationState.cs
- XmlReturnWriter.cs
- VirtualDirectoryMappingCollection.cs
- MemberHolder.cs
- TextCharacters.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- mactripleDES.cs
- CodeCatchClauseCollection.cs
- OdbcException.cs
- ContainerControl.cs
- RuleSettingsCollection.cs
- TableStyle.cs
- PointValueSerializer.cs
- XsltOutput.cs
- Emitter.cs
- EpmSyndicationContentSerializer.cs
- Expr.cs
- Assert.cs
- JobDuplex.cs
- OdbcException.cs
- RubberbandSelector.cs
- AssemblyLoader.cs
- StringStorage.cs
- ContentFilePart.cs
- PerformanceCounterPermissionEntry.cs
- Image.cs
- SHA256.cs
- DiagnosticTraceSource.cs