Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / Util / SimpleRecyclingCache.cs / 4 / 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. //------------------------------------------------------------------------------ //// 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UncommonField.cs
- OutKeywords.cs
- RoleService.cs
- DefaultMemberAttribute.cs
- ExitEventArgs.cs
- Itemizer.cs
- ProvidersHelper.cs
- QuaternionRotation3D.cs
- cookieexception.cs
- XMLDiffLoader.cs
- TreeNodeBindingDepthConverter.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- ImmutableObjectAttribute.cs
- EmptyCollection.cs
- ResourcePermissionBase.cs
- XmlSigningNodeWriter.cs
- MimeReturn.cs
- Container.cs
- XmlMapping.cs
- PathParser.cs
- XmlSchemaExternal.cs
- TabControlCancelEvent.cs
- TypeBrowserDialog.cs
- SslStream.cs
- ListViewTableRow.cs
- Membership.cs
- XmlIterators.cs
- FlowNode.cs
- QuadraticBezierSegment.cs
- Binding.cs
- FileEnumerator.cs
- DataContractSet.cs
- QuarticEase.cs
- RegexTree.cs
- X509ChainPolicy.cs
- Viewport3DAutomationPeer.cs
- TypeViewSchema.cs
- DataObjectEventArgs.cs
- PageBuildProvider.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- BitmapEffectCollection.cs
- TypeExtension.cs
- StaticSiteMapProvider.cs
- Base64Stream.cs
- AttachedPropertyMethodSelector.cs
- GridPatternIdentifiers.cs
- StateManagedCollection.cs
- HintTextConverter.cs
- XmlBinaryReader.cs
- externdll.cs
- ExpressionConverter.cs
- DbModificationClause.cs
- QueryCacheManager.cs
- GenericIdentity.cs
- LoadWorkflowCommand.cs
- ReadOnlyObservableCollection.cs
- ConsoleKeyInfo.cs
- SctClaimSerializer.cs
- RepeaterDesigner.cs
- HighlightComponent.cs
- AlternateView.cs
- DbException.cs
- UriTemplateLiteralPathSegment.cs
- Selector.cs
- OracleDataReader.cs
- SplayTreeNode.cs
- Msmq4SubqueuePoisonHandler.cs
- PointAnimation.cs
- EditingCoordinator.cs
- DBParameter.cs
- BufferedStream2.cs
- NetworkInterface.cs
- CounterNameConverter.cs
- PrimitiveDataContract.cs
- PlanCompilerUtil.cs
- FocusTracker.cs
- ManagementObject.cs
- AvTraceFormat.cs
- ShaperBuffers.cs
- FtpWebResponse.cs
- LifetimeManager.cs
- ListViewSelectEventArgs.cs
- IResourceProvider.cs
- RangeBaseAutomationPeer.cs
- _AuthenticationState.cs
- XsdValidatingReader.cs
- ConnectionStringsSection.cs
- RbTree.cs
- JpegBitmapDecoder.cs
- TypeElement.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- KeyedCollection.cs
- WebRequestModuleElementCollection.cs
- XmlnsPrefixAttribute.cs
- X509CertificateTokenFactoryCredential.cs
- NameObjectCollectionBase.cs
- TextRangeSerialization.cs
- RegexWorker.cs
- UriTemplateTrieNode.cs
- OleDbFactory.cs