eventium-memory: In-memory implementations for eventium

[ database, eventsourcing, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

Eventium-memory provides in-memory implementations of event stores, read models, and projection caches for the Eventium event sourcing framework. This package is ideal for development, testing, and prototyping event-sourced applications without requiring external dependencies like databases. All data is stored in STM-based concurrent data structures for thread-safe access.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0
Change log CHANGELOG.md
Dependencies base (>=4.9 && <5), containers (>=0.6 && <0.8), eventium-core, mtl (>=2.2 && <2.4), safe (>=0.3 && <0.4), stm (>=2.5 && <2.6) [details]
License MIT
Author
Maintainer Alexander Sidorenko
Category Database, Eventsourcing
Home page https://github.com/aleks-sidorenko/eventium#readme
Bug tracker https://github.com/aleks-sidorenko/eventium/issues
Source repo head: git clone https://github.com/aleks-sidorenko/eventium
Uploaded by aleks_sidorenko at 2025-12-15T08:51:14Z
Distributions
Downloads 1 total (1 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for eventium-memory-0.1.0

[back to package description]

Eventium Memory

In-memory implementations of event stores, read models, and projection caches for Eventium.

Overview

eventium-memory provides thread-safe, in-memory storage implementations for the Eventium event sourcing framework. This package is ideal for development, testing, and prototyping event-sourced applications without requiring external dependencies like databases.

Features

  • In-Memory Event Store - Fast, STM-based event storage
  • Thread-Safe - Concurrent access via Software Transactional Memory
  • No External Dependencies - No database setup required
  • Perfect for Testing - Fast test execution with isolated state
  • Projection Cache - In-memory snapshot storage
  • Read Model Support - Memory-based read model implementation

Components

Event Store (Eventium.Store.Memory)

Implements both EventStoreReader and EventStoreWriter with:

  • Per-stream versioning
  • Global event ordering
  • Optimistic concurrency control
  • STM transactions for atomicity

Read Model (Eventium.ReadModel.Memory)

In-memory read model implementation for building query-optimized views.

Projection Cache (Eventium.ProjectionCache.Memory)

Stores projection snapshots in memory to avoid replaying entire event histories.

Usage

import Eventium.Store.Memory (newEventStore)
import Control.Concurrent.STM (atomically)

main :: IO ()
main = do
  -- Create a new in-memory event store
  store <- atomically newEventStore
  
  -- Use it with your command handlers and projections
  result <- applyCommandHandler 
    (eventStoreWriter store)
    (eventStoreReader store) 
    myCommandHandler 
    aggregateId 
    command

Installation

Add to your package.yaml:

dependencies:
  - eventium-core
  - eventium-memory

Or to your .cabal file:

build-depends:
    eventium-core
  , eventium-memory

Use Cases

Development

Quickly prototype event-sourced applications without database setup.

Testing

  • Fast test execution (no I/O overhead)
  • Isolated test state (each test gets fresh store)
  • Easy verification of event sequences

Demonstration

Perfect for demos, tutorials, and learning event sourcing concepts.

Example

-- Create store
store <- atomically newEventStore

-- Write events
writeResult <- atomically $ 
  writeEvents (eventStoreWriter store) 
    streamKey 
    ExpectedPositionAny 
    [event1, event2]

-- Read events back
events <- atomically $ 
  readEvents (eventStoreReader store) 
    streamKey 
    QueryRangeAll

Limitations

  • Not Persistent - All data lost when process ends
  • Memory Constraints - Limited by available RAM
  • Single Process - No distributed access

For production use, consider:

  • eventium-sqlite - Persistent, single-process storage
  • eventium-postgresql - Persistent, multi-process storage

Documentation

License

MIT - see LICENSE.md