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
- Point3DAnimationUsingKeyFrames.cs
- SmtpException.cs
- ClientTargetSection.cs
- DbConnectionHelper.cs
- XmlSchemaSimpleContentRestriction.cs
- PermissionRequestEvidence.cs
- ApplicationBuildProvider.cs
- EventEntry.cs
- ModuleBuilder.cs
- ZoneButton.cs
- XMLSchema.cs
- CreateRefExpr.cs
- CommonObjectSecurity.cs
- BitStack.cs
- SqlRowUpdatedEvent.cs
- ReferenceEqualityComparer.cs
- SHA256Managed.cs
- UnitySerializationHolder.cs
- BindingGroup.cs
- XmlSchemaSimpleContentExtension.cs
- ConnectionString.cs
- DBSchemaTable.cs
- ObjectView.cs
- Int16.cs
- ObjectItemAssemblyLoader.cs
- DeflateEmulationStream.cs
- StateManagedCollection.cs
- IPHostEntry.cs
- ColorAnimation.cs
- SystemIPInterfaceStatistics.cs
- SafeWaitHandle.cs
- SettingsProviderCollection.cs
- GradientStop.cs
- HttpStaticObjectsCollectionWrapper.cs
- CacheHelper.cs
- SystemTcpConnection.cs
- Predicate.cs
- Utils.cs
- ImageMapEventArgs.cs
- RuntimeComponentFilter.cs
- DataGridViewLayoutData.cs
- BufferedReadStream.cs
- MappingItemCollection.cs
- WCFBuildProvider.cs
- HyperLinkColumn.cs
- IPEndPointCollection.cs
- HostingEnvironment.cs
- ClrProviderManifest.cs
- UrlAuthorizationModule.cs
- TreeNodeStyle.cs
- DataServiceQueryContinuation.cs
- TTSEvent.cs
- NavigatorInput.cs
- UpdateManifestForBrowserApplication.cs
- TemplatePropertyEntry.cs
- SocketManager.cs
- QueryStringParameter.cs
- StsCommunicationException.cs
- XmlNodeReader.cs
- Label.cs
- InstallerTypeAttribute.cs
- ByteAnimationUsingKeyFrames.cs
- TextElementAutomationPeer.cs
- AutoGeneratedFieldProperties.cs
- TemplateControlParser.cs
- FigureParaClient.cs
- HttpCookieCollection.cs
- ParseChildrenAsPropertiesAttribute.cs
- CodeArrayIndexerExpression.cs
- ResponseStream.cs
- RegexCharClass.cs
- ToolStripComboBox.cs
- AdjustableArrowCap.cs
- PrivilegedConfigurationManager.cs
- RoutedEventArgs.cs
- SerialReceived.cs
- TraceSection.cs
- StaticResourceExtension.cs
- SHA256Managed.cs
- WorkflowInstance.cs
- CompilationUnit.cs
- Configuration.cs
- NativeRightsManagementAPIsStructures.cs
- Soap.cs
- RangeExpression.cs
- FileDialog_Vista.cs
- HandlerFactoryCache.cs
- AppSettingsReader.cs
- DescendantBaseQuery.cs
- FrameworkRichTextComposition.cs
- ITreeGenerator.cs
- DotExpr.cs
- FlowPosition.cs
- HMACSHA1.cs
- SupportsEventValidationAttribute.cs
- DesignerCategoryAttribute.cs
- ListItemCollection.cs
- HttpPostProtocolImporter.cs
- ClientRoleProvider.cs
- DrawingBrush.cs