XYLEX Group

Storage

Persistence implementations

Storage

Worlds Engine provides pluggable backend for storage using different strategies.

Memory Store

In-memory storage using JavaScript Maps.

  • Pros: Extremely fast, zero I/O overhead
  • Cons: Loses all state on process termination
  • Use Case: Testing, development, ephemeral workloads
const world = new World({ persistence: 'memory' });

File Store

Filesystem-based storage using JSON files in .worlds-engine directory.

  • Pros: Durable across process restarts, human-readable
  • Cons: Slower due to I/O operations
  • Use Case: Single-node production, simple deployments
const world = new World({
  persistence: 'file',
  persistencePath: '.worlds-engine'
});

Directory Structure

.worlds-engine/
├── workflows/
│   └── {workflowId}.json
├── schedules/
│   └── {scheduleId}.json
├── logs/
│   └── {date}.log
├── state/
└── queue.json

Hybrid Store

Combines memory and file storage. Maintains state in memory for speed, with periodic (5s) background sync to disk for durability.

  • Pros: Speed of memory, durability of files
  • Cons: Potential for small data loss on hard crash (last 5s)
  • Use Case: High-performance production
const world = new World({ persistence: 'hybrid' });

Initialization Sequence:

  1. Create file storage directories
  2. Load workflows from disk into memory
  3. Load schedules from disk into memory
  4. Load queue from disk into memory
  5. Start periodic sync interval