Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data ProjectionCache key position serialized m = ProjectionCache {
- storeProjectionSnapshot :: key -> position -> serialized -> m ()
- loadProjectionSnapshot :: key -> m (Maybe (position, serialized))
- type VersionedProjectionCache serialized m = ProjectionCache UUID EventVersion serialized m
- type GlobalStreamProjectionCache key serialized m = ProjectionCache key SequenceNumber serialized m
- runProjectionCacheUsing :: (Monad m, Monad mstore) => (forall a. mstore a -> m a) -> ProjectionCache key position serialized mstore -> ProjectionCache key position serialized m
- serializedProjectionCache :: Monad m => Serializer state serialized -> ProjectionCache key position serialized m -> ProjectionCache key position state m
- getLatestVersionedProjectionWithCache :: Monad m => VersionedEventStoreReader m event -> VersionedProjectionCache state m -> VersionedStreamProjection state event -> m (VersionedStreamProjection state event)
- getLatestGlobalProjectionWithCache :: Monad m => GlobalEventStoreReader m event -> GlobalStreamProjectionCache key state m -> GlobalStreamProjection state event -> key -> m (GlobalStreamProjection state event)
- updateProjectionCache :: Monad m => VersionedEventStoreReader m event -> VersionedProjectionCache state m -> VersionedStreamProjection state event -> m ()
- updateGlobalProjectionCache :: Monad m => GlobalEventStoreReader m event -> GlobalStreamProjectionCache key state m -> GlobalStreamProjection state event -> key -> m ()
Documentation
data ProjectionCache key position serialized m Source #
A ProjectionCache
caches snapshots of Projection
s in event streams.
This is useful if your event streams are very large. This cache operates on
some Monad
m
and stores the Projection
state of type serialized
.
At its core, this is essentially just a key-value store with knowledge of
the stream UUID
and EventVersion
. It is recommended to use the other
helper functions in this module to interpret the stored values using a
Projection
.
The key
and position
type parameters are polymorphic so we can abstract
over a cache for individual event streams, and a cache for globally ordered
streams.
ProjectionCache | |
|
type VersionedProjectionCache serialized m = ProjectionCache UUID EventVersion serialized m Source #
Type synonym for a ProjectionCache
used on individual event streams.
type GlobalStreamProjectionCache key serialized m = ProjectionCache key SequenceNumber serialized m Source #
Type synonym for a ProjectionCache
that is used in conjunction with a
GlobalStreamEventStore
.
runProjectionCacheUsing :: (Monad m, Monad mstore) => (forall a. mstore a -> m a) -> ProjectionCache key position serialized mstore -> ProjectionCache key position serialized m Source #
Changes the monad a ProjectionCache
runs in. This is useful to run the
cache in another Monad
while forgetting the original Monad
.
serializedProjectionCache :: Monad m => Serializer state serialized -> ProjectionCache key position serialized m -> ProjectionCache key position state m Source #
Wraps a ProjectionCache
and transparently serializes/deserializes events for
you. Note that in this implementation deserialization errors when using
getEvents
are simply ignored (the event is not returned).
getLatestVersionedProjectionWithCache :: Monad m => VersionedEventStoreReader m event -> VersionedProjectionCache state m -> VersionedStreamProjection state event -> m (VersionedStreamProjection state event) Source #
Like getLatestVersionedProjection
, but uses a ProjectionCache
if it contains
more recent state.
getLatestGlobalProjectionWithCache :: Monad m => GlobalEventStoreReader m event -> GlobalStreamProjectionCache key state m -> GlobalStreamProjection state event -> key -> m (GlobalStreamProjection state event) Source #
Like getLatestGlobalProjection
, but uses a ProjectionCache
if it
contains more recent state.
updateProjectionCache :: Monad m => VersionedEventStoreReader m event -> VersionedProjectionCache state m -> VersionedStreamProjection state event -> m () Source #
Loads the latest projection state from the cache/store and stores this value back into the projection cache.
updateGlobalProjectionCache :: Monad m => GlobalEventStoreReader m event -> GlobalStreamProjectionCache key state m -> GlobalStreamProjection state event -> key -> m () Source #
Analog of updateProjectionCache
for a GlobalStreamProjectionCache
.