InterprocessCache Class

Represents a serialized data cache that can be saved or read from multiple applications using inter-process synchronization.

Definition

Namespace: Gemstone.IO
Assembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.128 -- Release Build+d050cfc5563c89a1188cc3c6b2d417530856f490
public class InterprocessCache : IDisposable
Inheritance
Object    InterprocessCache
Implements
IDisposable

Remarks

Note that all file data in this class gets serialized to and from memory, as such, the design intention for this class is for use with smaller data sets such as serialized lists or dictionaries that need inter-process synchronized loading and saving.

The InterprocessCache uses a NamedSemaphore to synchronize access to cache as an inter-process shared resource. On POSIX systems, the NamedSemaphore exhibits kernel persistence, meaning instances will remain active beyond the lifespan of the creating process. The named semaphore must be explicitly removed by invoking ReleaseInterprocessResources when the last interprocess cache instance is no longer needed. Kernel persistence necessitates careful design consideration regarding process responsibility for invoking the ReleaseInterprocessResources method. Since the common use case for named semaphores is across multiple applications, it is advisable for the last exiting process to handle the cleanup. In cases where an application may crash before calling the ReleaseInterprocessResources method, the semaphore persists in the system, potentially leading to resource leakage. Implementations should include strategies to address and mitigate this risk.

Constructors

InterprocessCache Creates a new instance of the InterprocessCache.
InterprocessCache(Int32) Creates a new instance of the InterprocessCache with the specified number of maximumConcurrentLocks.

Properties

AutoSave Gets or sets flag that determines if InterprocessCache should automatically initiate a save when FileData has been updated.
FileData Gets or sets file data for the cache to be saved or that has been loaded.
FileName Path and file name for the cache needing inter-process synchronization.
MaximumConcurrentLocks Gets the maximum concurrent reader locks allowed.
MaximumRetryAttempts Maximum retry attempts allowed for loading or saving cache file data.
ReloadOnChange Gets or sets flag that enables system to monitor for changes in FileName and automatically reload FileData.
RetryDelayInterval Wait interval, in milliseconds, before retrying load or save of cache file data.

Methods

Dispose Releases all the resources used by the InterprocessCache object.
Dispose(Boolean) Releases the unmanaged resources used by the InterprocessCache object and optionally releases the managed resources.
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Finalize Releases the unmanaged resources before the InterprocessCache object is reclaimed by GC.
(Overrides ObjectFinalize)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
Load Initiates inter-process synchronized cache file load.
LoadFileData Handles deserialization of file from disk; virtual method allows customization (e.g., pre-load decryption and/or data merge).
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
ReleaseInterprocessResources Releases the inter-process resources used by the InterprocessCache.
Save Initiates inter-process synchronized cache file save.
SaveFileData Handles serialization of file to disk; virtual method allows customization (e.g., pre-save encryption and/or data merge).
ToStringReturns a string that represents the current object.
(Inherited from Object)
WaitForLoad Blocks current thread and waits for any pending load to complete; wait time is RetryDelayInterval * MaximumRetryAttempts.
WaitForLoad(Int32) Blocks current thread and waits for specified millisecondsTimeout for any pending load to complete.
WaitForSave Blocks current thread and waits for any pending save to complete; wait time is RetryDelayInterval * MaximumRetryAttempts.
WaitForSave(Int32) Blocks current thread and waits for specified millisecondsTimeout for any pending save to complete.

Fields

DefaultMaximumRetryAttempts Default maximum retry attempts allowed for loading InterprocessCache.
DefaultRetryDelayInterval Default wait interval, in milliseconds, before retrying load of InterprocessCache.

Extension Methods

GetEnumValueOrDefault Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
GetEnumValueOrDefaultT Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)

See Also