LockFreeCacheOptionsThresholdCapacity Property

Gets or sets the maximum number of elements, which triggers a merge operation from the underlying dynamic growing storage into the faster read-only storage. Specifies also the number of elements to be kept when older elements are dropped from the cache. The actual maximum number of stored items may be about twice of this value.
Default value: 1024.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
public int ThresholdCapacity { get; set; }

Property Value

Int32

Remarks

The value of the ThresholdCapacity property must be greater than or equal to the value of the InitialCapacity property.

When the first element is about to be stored a dynamic storage is allocated that can optimally store about as many elements as specified by the InitialCapacity property. When the number of stored elements reaches InitialCapacity capacity, then the content of the dynamic storage is copied into a faster read-only storage, and for additional elements a new dynamic storage is allocated with either doubled capacity or the specified ThresholdCapacity, whichever is less.

Once the number of stored elements in the dynamically growing storage reaches ThresholdCapacity, the complete previous content of the faster read-only storage is replaced by the elements in the growing storage. Therefore, when adding new items continuously, the number of stored elements will be between ThresholdCapacity and twice of ThresholdCapacity.

If it cannot be really estimated how many items in the cache will be stored, then you can set the MergeInterval property, which can trigger a merge operation to the faster storage by time, regardless of reaching the required capacity limit.

See Also