Class MemoryCacheEventStore<TAuthenticationToken>
A, EventStore<TAuthenticationToken> that uses a System.Runtime.Caching.MemoryCache implementation, flushing out data (I.E. it's not persisted)
Inheritance
Inherited Members
Namespace: Cqrs.Events
Assembly: Cqrs.dll
Syntax
public class MemoryCacheEventStore<TAuthenticationToken> : EventStore<TAuthenticationToken>, IEventStore<TAuthenticationToken>
Type Parameters
Name | Description |
---|---|
TAuthenticationToken |
Constructors
MemoryCacheEventStore(IConfigurationManager, IEventBuilder<TAuthenticationToken>, IEventDeserialiser<TAuthenticationToken>, ILogger)
Instantiates a new instance of MemoryCacheEventStore<TAuthenticationToken> and calls StartRefreshSlidingExpirationValue().
Declaration
public MemoryCacheEventStore(IConfigurationManager configurationManager, IEventBuilder<TAuthenticationToken> eventBuilder, IEventDeserialiser<TAuthenticationToken> eventDeserialiser, ILogger logger)
Parameters
Type | Name | Description |
---|---|---|
IConfigurationManager | configurationManager | |
IEventBuilder<TAuthenticationToken> | eventBuilder | |
IEventDeserialiser<TAuthenticationToken> | eventDeserialiser | |
cdmdotnet.Logging.ILogger | logger |
Properties
ConfigurationManager
Gets or sets the IConfigurationManager.
Declaration
protected IConfigurationManager ConfigurationManager { get; }
Property Value
Type | Description |
---|---|
IConfigurationManager |
EventStoreByCorrelationId
Gets or sets the System.Runtime.Caching.MemoryCache of data grouped by event CorrelationId.
Declaration
protected MemoryCache EventStoreByCorrelationId { get; }
Property Value
Type | Description |
---|---|
System.Runtime.Caching.MemoryCache |
EventStoreByType
Gets or sets the System.Runtime.Caching.MemoryCache of data grouped by event System.Type.
Declaration
protected MemoryCache EventStoreByType { get; }
Property Value
Type | Description |
---|---|
System.Runtime.Caching.MemoryCache |
SlidingExpiration
Gets of sets the SlidingExpiration
Declaration
protected TimeSpan SlidingExpiration { get; set; }
Property Value
Type | Description |
---|---|
System.TimeSpan |
SlidingExpirationValue
Gets of sets the SlidingExpirationValue, the value of "Cqrs.EventStore.MemoryCacheEventStore.SlidingExpiration" from ConfigurationManager.
Declaration
protected string SlidingExpirationValue { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Methods
Get(Guid)
Get all IEvent<TAuthenticationToken> instances for the given correlationId
.
Declaration
public override IEnumerable<EventData> Get(Guid correlationId)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | correlationId | The CorrelationId of the IEvent<TAuthenticationToken> instances to retrieve. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<EventData> |
Overrides
Get(Type, Guid, Boolean, Int32)
Gets a collection of IEvent<TAuthenticationToken> for the IAggregateRoot<TAuthenticationToken> of type aggregateRootType
with the ID matching the provided aggregateId
.
Declaration
public override IEnumerable<IEvent<TAuthenticationToken>> Get(Type aggregateRootType, Guid aggregateId, bool useLastEventOnly = false, int fromVersion = -1)
Parameters
Type | Name | Description |
---|---|---|
System.Type | aggregateRootType | System.Type of the IAggregateRoot<TAuthenticationToken> the IEvent<TAuthenticationToken> was raised in. |
System.Guid | aggregateId | The Id of the IAggregateRoot<TAuthenticationToken>. |
System.Boolean | useLastEventOnly | Loads only the last eventIEvent<TAuthenticationToken>. |
System.Int32 | fromVersion | Load events starting from this version |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IEvent<TAuthenticationToken>> |
Overrides
GetDetaultCacheItemPolicy()
Get's a System.Runtime.Caching.CacheItemPolicy with the System.Runtime.Caching.CacheItemPolicy.SlidingExpiration set to 15 minutes
Declaration
protected virtual CacheItemPolicy GetDetaultCacheItemPolicy()
Returns
Type | Description |
---|---|
System.Runtime.Caching.CacheItemPolicy |
PersistEvent(EventData)
Persist the provided eventData
into storage.
Declaration
protected override void PersistEvent(EventData eventData)
Parameters
Type | Name | Description |
---|---|---|
EventData | eventData | The EventData to persist. |
Overrides
RefreshSlidingExpirationValue()
Reads "Cqrs.EventStore.MemoryCacheEventStore.SlidingExpiration" from ConfigurationManager, checks if it has changed and then Update SlidingExpiration with the new value.
Declaration
protected virtual void RefreshSlidingExpirationValue()
StartRefreshSlidingExpirationValue()
Start a System.Threading.Tasks.Task that will call RefreshSlidingExpirationValue() in a loop with a 1 second wait time between loops.
Declaration
protected virtual void StartRefreshSlidingExpirationValue()