Skip to main content

Installation

Install with Composer

composer require domainflow/event-sourcing-redis

Connect the adapter

The adapter accepts a connected Redis extension client:

use DomainFlow\EventSourcing\Facade\EventSourcingFacade;
use DomainFlow\EventSourcing\Snapshot\GenericSnapshotFactory;
use DomainFlow\EventSourcingRedis\Snapshot\RedisSnapshotStorage;
use DomainFlow\EventSourcingRedis\Storage\RedisEventStorage;
use Redis;

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);

$facade = new EventSourcingFacade(
new RedisEventStorage($redis),
new RedisSnapshotStorage($redis),
new GenericSnapshotFactory(),
);

Snapshots are optional. Event history remains the source of truth.

Verify the deployment

Redis has no table or index DDL. RedisSchemaManager::ensureSchema() verifies the durability settings required by the event store:

use DomainFlow\EventSourcingRedis\Schema\RedisSchemaManager;

(new RedisSchemaManager($redis))->ensureSchema();

The same check runs when RedisEventStorage is constructed by default. If a managed Redis service does not allow CONFIG GET, verify the settings through that service and pass assertDurableConfiguration: false explicitly:

$storage = new RedisEventStorage(
$redis,
assertDurableConfiguration: false,
);

Only use this opt-out after the equivalent durability checks have been made outside the adapter.