Class ObjectStoreDaemon
Implements service that stores object in proccess's memory, asynchronously saving objects to external non-volatile storage
upon change and synchronously saving objects upon service stop. This service is useful for scenarios like ASP.NET
volatile domain that can be torn down at any time.
Note for ASP.NET uses: the key difference of this approach from .NET session state management is the fact that this service never blocks
object CheckIn() operations as backing store is being updated asynchronously.
This class is thread-safe unless specified otherwise on a property/method level
Inheritance
System.Object
ObjectStoreDaemon
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Azos.dll
Syntax
[ConfigMacroContext]
public class ObjectStoreDaemon : DaemonWithInstrumentation<IApplicationComponent>, IDaemon, IDaemonView, INamed, IObjectStoreImplementation, IObjectStore, IApplicationComponent, ILocalizedTimeProvider, IDisposable, IConfigurable, IInstrumentable, IExternallyParameterized
Constructors
ObjectStoreDaemon(IApplicationComponent)
Creates instance of the store service
Declaration
public ObjectStoreDaemon(IApplicationComponent director)
Parameters
ObjectStoreDaemon(IApplication)
Creates instance of the store service
Declaration
public ObjectStoreDaemon(IApplication app)
Parameters
Fields
CONFIG_BUCKET_COUNT_ATTR
Declaration
public const string CONFIG_BUCKET_COUNT_ATTR = "bucket-count"
Field Value
Type |
Description |
System.String |
|
CONFIG_GUID_ATTR
Declaration
public const string CONFIG_GUID_ATTR = "guid"
Field Value
Type |
Description |
System.String |
|
CONFIG_OBJECT_LIFE_SPAN_MS_ATTR
Declaration
public const string CONFIG_OBJECT_LIFE_SPAN_MS_ATTR = "object-life-span-ms"
Field Value
Type |
Description |
System.String |
|
CONFIG_PROVIDER_SECT
Declaration
public const string CONFIG_PROVIDER_SECT = "provider"
Field Value
Type |
Description |
System.String |
|
DEFAULT_BUCKET_COUNT
Declaration
public const int DEFAULT_BUCKET_COUNT = 1024
Field Value
Type |
Description |
System.Int32 |
|
DEFAULT_OBJECT_LEFESPAN_MS
Declaration
public const int DEFAULT_OBJECT_LEFESPAN_MS = 3600000
Field Value
Type |
Description |
System.Int32 |
|
MAX_BUCKET_COUNT
Declaration
public const int MAX_BUCKET_COUNT = 65535
Field Value
Type |
Description |
System.Int32 |
|
MIN_OBJECT_LIFESPAN_MS
Declaration
public const int MIN_OBJECT_LIFESPAN_MS = 1000
Field Value
Type |
Description |
System.Int32 |
|
MUST_ACQUIRE_INTERVAL_MS
Declaration
public const int MUST_ACQUIRE_INTERVAL_MS = 3000
Field Value
Type |
Description |
System.Int32 |
|
Properties
BucketCount
Specifies how many buckets objects are kept in. Increasing this number improves thread concurrency
Declaration
public int BucketCount { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
ComponentCommonName
Declaration
public override string ComponentCommonName { get; }
Property Value
Type |
Description |
System.String |
|
Overrides
ComponentLogTopic
Declaration
public override string ComponentLogTopic { get; }
Property Value
Type |
Description |
System.String |
|
Overrides
InstrumentationEnabled
Implements IInstrumentable
Declaration
[Config(Default = false)]
[ExternalParameter(new string[]{"objectstore", "instrumentation"})]
public override bool InstrumentationEnabled { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Overrides
Azos.Apps.DaemonWithInstrumentation<Azos.Apps.IApplicationComponent>.InstrumentationEnabled
ObjectLifeSpanMS
Specifies how long objects live without being touched before becoming evicted from the list
Declaration
[ExternalParameter(new string[]{"objectstore"})]
public int ObjectLifeSpanMS { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
Provider
References provider that persists objects
Declaration
public ObjectStoreProvider Provider { get; set; }
Property Value
StoreGUID
Returns unique identifier that identifies this particular store.
This ID is used to load store's state from external medium upon start-up.
One may think of this ID as of a "pointer/handle" that survives physical object destroy/create cycle
Declaration
public Guid StoreGUID { get; set; }
Property Value
Type |
Description |
System.Guid |
|
Methods
CheckIn(Guid, Int32)
Puts an object back into store identified by the "key".
The object is written in the provider when call count to this method equals to CheckOut().
Returns true if object with such id exists and was checked-in
Declaration
public bool CheckIn(Guid key, int msTimeout = 0)
Parameters
Type |
Name |
Description |
System.Guid |
key |
|
System.Int32 |
msTimeout |
|
Returns
Type |
Description |
System.Boolean |
|
CheckIn(Guid, Object, Int32)
Puts an object reference "value" into store identified by the "key".
The object is written in the provider when call count to this method equals to CheckOut()
Declaration
public void CheckIn(Guid key, object value, int msTimeout = 0)
Parameters
Type |
Name |
Description |
System.Guid |
key |
|
System.Object |
value |
|
System.Int32 |
msTimeout |
|
CheckInUnderNewKey(Guid, Guid, Object, Int32)
Puts an object reference "value" into store identified by the "oldKey" under the "newKey".
If oldKey was not checked in, then checks-in under new key as normally would
Declaration
public void CheckInUnderNewKey(Guid oldKey, Guid newKey, object value, int msTimeout = 0)
Parameters
Type |
Name |
Description |
System.Guid |
oldKey |
|
System.Guid |
newKey |
|
System.Object |
value |
|
System.Int32 |
msTimeout |
|
CheckOut(Guid)
Retrieves an object reference from the store identified by the "key" or returns null if such object does not exist.
Object is not going to be persisted until it is checked back in the store using the same number of calls to CheckIn() for the same GUID.
Declaration
public object CheckOut(Guid key)
Parameters
Type |
Name |
Description |
System.Guid |
key |
|
Returns
Type |
Description |
System.Object |
|
Delete(Guid)
Deletes object identified by key. Returns true when object was found and marked for deletion
Declaration
public bool Delete(Guid key)
Parameters
Type |
Name |
Description |
System.Guid |
key |
|
Returns
Type |
Description |
System.Boolean |
|
Declaration
protected override void DoConfigure(IConfigSectionNode node)
Parameters
Overrides
DoSignalStop()
Declaration
protected override void DoSignalStop()
Overrides
DoStart()
Declaration
protected override void DoStart()
Overrides
DoWaitForCompleteStop()
Declaration
protected override void DoWaitForCompleteStop()
Overrides
Fetch(Guid, Boolean)
Retrieves an object reference from the store identified by the "key" or returns null if such object does not exist.
Object is not going to be persisted as this method provides logical read-only access. If touch=true then object timestamp is updated
Declaration
public object Fetch(Guid key, bool touch = false)
Parameters
Type |
Name |
Description |
System.Guid |
key |
|
System.Boolean |
touch |
|
Returns
Type |
Description |
System.Object |
|
UndoCheckout(Guid)
Reverts object state to Normal after the call to Checkout. This way the changes (if any) are not going to be persisted.
Returns true if object was found and checkout canceled. Keep in mind: this method CAN NOT revert inner object state
to its original state if it was changed, it only unmarks object as changed.
This method is reentrant just like the Checkout is
Declaration
public bool UndoCheckout(Guid key)
Parameters
Type |
Name |
Description |
System.Guid |
key |
|
Returns
Type |
Description |
System.Boolean |
|
visit(Boolean)
Declaration
public void visit(bool stopping)
Parameters
Type |
Name |
Description |
System.Boolean |
stopping |
|
Implements
System.IDisposable
Extension Methods