Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- BaseTemplateBuildProvider.cs
- Rules.cs
- SqlParameter.cs
- HandleRef.cs
- StringExpressionSet.cs
- Int64Converter.cs
- RenderDataDrawingContext.cs
- ITextView.cs
- IntAverageAggregationOperator.cs
- TraceEventCache.cs
- DateTimeSerializationSection.cs
- SelectionProcessor.cs
- ProcessStartInfo.cs
- ResponseBodyWriter.cs
- RuntimeConfigurationRecord.cs
- DefaultClaimSet.cs
- OdbcDataAdapter.cs
- SqlExpander.cs
- ElementHostAutomationPeer.cs
- TextShapeableCharacters.cs
- WebPartDisplayMode.cs
- DataFieldEditor.cs
- SqlMultiplexer.cs
- Highlights.cs
- CheckedListBox.cs
- XmlTextAttribute.cs
- TableLayoutStyleCollection.cs
- DefinitionUpdate.cs
- ResourceAssociationSet.cs
- PreservationFileWriter.cs
- DescendantQuery.cs
- DownloadProgressEventArgs.cs
- GetPageCompletedEventArgs.cs
- DataServiceQueryException.cs
- SendMailErrorEventArgs.cs
- HtmlElementEventArgs.cs
- DbConnectionPoolIdentity.cs
- GenericsNotImplementedException.cs
- DropSource.cs
- PropertyOverridesDialog.cs
- NumericPagerField.cs
- PropertySegmentSerializationProvider.cs
- FormatVersion.cs
- MessageUtil.cs
- PropertyMap.cs
- ConfigXmlCDataSection.cs
- FixedLineResult.cs
- ContentPlaceHolder.cs
- activationcontext.cs
- RegexWriter.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- CatalogPart.cs
- ThemeableAttribute.cs
- Int16.cs
- DashStyles.cs
- IssuedTokenServiceCredential.cs
- SplineQuaternionKeyFrame.cs
- LongValidatorAttribute.cs
- CompilationRelaxations.cs
- EditCommandColumn.cs
- CheckBox.cs
- DBSchemaTable.cs
- QueryCacheEntry.cs
- ViewStateException.cs
- InputLanguageCollection.cs
- RectAnimationUsingKeyFrames.cs
- InternalDuplexChannelFactory.cs
- NullableIntMinMaxAggregationOperator.cs
- CompressedStack.cs
- Localizer.cs
- XmlBinaryReader.cs
- UrlPropertyAttribute.cs
- SByteStorage.cs
- XDRSchema.cs
- ScanQueryOperator.cs
- ThicknessKeyFrameCollection.cs
- QilTypeChecker.cs
- unitconverter.cs
- TypeLoadException.cs
- KerberosSecurityTokenAuthenticator.cs
- NotifyIcon.cs
- DataServiceHostFactory.cs
- TextStore.cs
- TransformerInfo.cs
- FigureParagraph.cs
- WebServiceData.cs
- DbProviderServices.cs
- EntityParameterCollection.cs
- DispatcherExceptionFilterEventArgs.cs
- DataGridState.cs
- GrammarBuilder.cs
- CodeRegionDirective.cs
- wmiutil.cs
- XComponentModel.cs
- TextServicesDisplayAttribute.cs
- ComponentEditorForm.cs
- ScriptResourceMapping.cs
- HostingPreferredMapPath.cs
- ContainerSelectorActiveEvent.cs
- _ShellExpression.cs