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
- UpDownBase.cs
- SqlUdtInfo.cs
- Renderer.cs
- GroupBoxRenderer.cs
- BitmapEffectvisualstate.cs
- ping.cs
- PropertyTabAttribute.cs
- TabControl.cs
- TimestampInformation.cs
- PeerNameRecord.cs
- BaseCollection.cs
- LayoutEditorPart.cs
- TextEditorTables.cs
- SimpleFileLog.cs
- TemplateXamlTreeBuilder.cs
- DoubleCollectionConverter.cs
- CodeMemberProperty.cs
- ImpersonateTokenRef.cs
- SmtpFailedRecipientException.cs
- SafeNativeMethods.cs
- Queue.cs
- XmlUtilWriter.cs
- HashRepartitionEnumerator.cs
- cookie.cs
- SecurityDescriptor.cs
- ButtonRenderer.cs
- Knowncolors.cs
- TextTreeTextNode.cs
- Error.cs
- TimeSpanConverter.cs
- PrincipalPermissionMode.cs
- SerializationInfo.cs
- DefaultExpression.cs
- EntryPointNotFoundException.cs
- Transform3D.cs
- ContextQuery.cs
- Journal.cs
- CornerRadiusConverter.cs
- ComplexLine.cs
- PipelineModuleStepContainer.cs
- ArraySet.cs
- Animatable.cs
- ListViewDeletedEventArgs.cs
- Keywords.cs
- TraceEventCache.cs
- AnnotationResource.cs
- CfgArc.cs
- unitconverter.cs
- ToolStripItemImageRenderEventArgs.cs
- SocketInformation.cs
- SelectionGlyph.cs
- VectorAnimation.cs
- DictionarySectionHandler.cs
- XmlTextWriter.cs
- DataGridCell.cs
- WebResponse.cs
- PageHandlerFactory.cs
- XhtmlBasicTextViewAdapter.cs
- ServiceModelConfigurationSectionCollection.cs
- CriticalHandle.cs
- SerialPort.cs
- ExtenderProvidedPropertyAttribute.cs
- Array.cs
- ConstraintStruct.cs
- FormViewPagerRow.cs
- ServiceModelPerformanceCounters.cs
- StreamUpdate.cs
- StringOutput.cs
- XmlCharCheckingReader.cs
- DNS.cs
- DataServiceEntityAttribute.cs
- HtmlTableCellCollection.cs
- List.cs
- DeflateEmulationStream.cs
- ThicknessAnimationBase.cs
- BindingValueChangedEventArgs.cs
- WebPartCancelEventArgs.cs
- ShapeTypeface.cs
- DbReferenceCollection.cs
- ForAllOperator.cs
- ConnectionPoint.cs
- ScriptRegistrationManager.cs
- Listbox.cs
- CopyOfAction.cs
- ConfigXmlText.cs
- ServiceDescription.cs
- NameScopePropertyAttribute.cs
- KeyFrames.cs
- OleDbInfoMessageEvent.cs
- figurelengthconverter.cs
- WindowsSpinner.cs
- UntypedNullExpression.cs
- WCFModelStrings.Designer.cs
- _UriSyntax.cs
- XmlHelper.cs
- StandardOleMarshalObject.cs
- HttpFileCollectionBase.cs
- ComponentChangingEvent.cs
- IdleTimeoutMonitor.cs
- TokenizerHelper.cs