Skip to main content

EGET

Retrieve an event by its unique identifier.

Syntax

EGET <event_id>

Parameters

ParameterTypeRequiredDescription
event_idUUIDYesUUID of the event to retrieve

Return Value

Map or Null: If the event exists, returns a map containing the complete event record. If not found, returns null.

Event Map Structure:

{
"event_id": "550e8400-e29b-41d4-a716-446655440000",
"partition_key": "550e8400-e29b-41d4-a716-446655440000",
"partition_id": 7,
"transaction_id": "550e8400-e29b-41d4-a716-446655440000",
"partition_sequence": 1234,
"stream_version": 4,
"timestamp": 1697641800000,
"stream_id": "user-123",
"event_name": "UserRegistered",
"metadata": "base64-encoded-data",
"payload": "base64-encoded-data"
}
  • event_id: UUID of the event
  • partition_key: UUID used for partitioning
  • partition_id: Partition number (0 to partition_count-1)
  • transaction_id: UUID of the transaction that created this event
  • partition_sequence: Sequence number within the partition
  • stream_version: Version number within the stream
  • timestamp: Event timestamp in milliseconds since Unix epoch
  • stream_id: Stream identifier
  • event_name: Event type name
  • metadata: Event metadata (base64-encoded)
  • payload: Event payload (base64-encoded)

Examples

Get Existing Event

EGET 550e8400-e29b-41d4-a716-446655440000

Returns:

{
"event_id": "550e8400-e29b-41d4-a716-446655440000",
"partition_key": "550e8400-e29b-41d4-a716-446655440000",
"partition_id": 7,
"transaction_id": "550e8400-e29b-41d4-a716-446655440000",
"partition_sequence": 1234,
"stream_version": 1,
"timestamp": 1697641800000,
"stream_id": "user-123",
"event_name": "EmailVerified",
"metadata": "eyJzb3VyY2UiOiJhcGkifQ==",
"payload": "eyJ2ZXJpZmllZF9hdCI6IjIwMjQtMDEtMDFUMTI6MDA6MDBaIn0="
}

Get Non-existent Event

EGET 00000000-0000-0000-0000-000000000000

Returns:

null

Client Examples

Python

import redis
import base64
import json

client = redis.Redis(host='localhost', port=9090, protocol=3)

# Get an event
event = client.execute_command('EGET', '550e8400-e29b-41d4-a716-446655440000')

if event is not None:
# Decode payload and metadata
payload = json.loads(base64.b64decode(event['payload']).decode('utf-8'))
metadata = json.loads(base64.b64decode(event['metadata']).decode('utf-8'))

print(f"Event: {event['event_name']} in stream {event['stream_id']}")
print(f"Payload: {payload}")
print(f"Metadata: {metadata}")
else:
print("Event not found")

JavaScript

const redis = require('redis');

const client = redis.createClient({
socket: { host: 'localhost', port: 9090 },
RESP: 3
});

await client.connect();

// Get an event
const event = await client.sendCommand(['EGET', '550e8400-e29b-41d4-a716-446655440000']);

if (event !== null) {
// Decode payload and metadata
const payload = JSON.parse(Buffer.from(event.payload, 'base64').toString('utf-8'));
const metadata = JSON.parse(Buffer.from(event.metadata, 'base64').toString('utf-8'));

console.log(`Event: ${event.event_name} in stream ${event.stream_id}`);
console.log('Payload:', payload);
console.log('Metadata:', metadata);
} else {
console.log('Event not found');
}

await client.disconnect();

Rust

use redis::{Commands, RedisResult};
use std::collections::HashMap;
use base64;

fn get_event(event_id: &str) -> RedisResult<Option<HashMap<String, redis::Value>>> {
let client = redis::Client::open("redis://127.0.0.1:9090/")?;
let mut con = client.get_connection()?;

let result: Option<HashMap<String, redis::Value>> = redis::cmd("EGET")
.arg(event_id)
.query(&mut con)?;

Ok(result)
}

fn main() -> RedisResult<()> {
match get_event("550e8400-e29b-41d4-a716-446655440000")? {
Some(event) => {
println!("Found event: {:?}", event);
},
None => {
println!("Event not found");
}
}

Ok(())
}

Use Cases

Event Debugging

Get complete event details for debugging:

def debug_event(event_id):
event = client.execute_command('EGET', event_id)
if event:
print(f"Event ID: {event['event_id']}")
print(f"Stream: {event['stream_id']} v{event['stream_version']}")
print(f"Partition: {event['partition_id']} seq {event['partition_sequence']}")
print(f"Timestamp: {event['timestamp']}")
print(f"Type: {event['event_name']}")
else:
print(f"Event {event_id} not found")

Event Audit Trail

Check if specific events exist:

def verify_events_exist(event_ids):
missing_events = []
for event_id in event_ids:
event = client.execute_command('EGET', event_id)
if event is None:
missing_events.append(event_id)
return missing_events

Event Content Inspection

Examine event payload without scanning entire streams:

def inspect_event_payload(event_id):
event = client.execute_command('EGET', event_id)
if event:
payload = json.loads(base64.b64decode(event['payload']))
return payload
return None

Error Responses

Invalid UUID Format

EGET invalid-uuid
-SYNTAX_ERROR Invalid UUID format

Performance Notes

  • O(1) lookup: Uses event ID index for fast retrieval
  • Bloom filters: First checks bloom filter to avoid disk reads for non-existent events
  • Cache-friendly: Recently accessed events may be cached in memory
  • Cross-partition: Can find events across any partition
  • EAPPEND - Append events that can later be retrieved
  • ESCAN - Read events from a stream
  • EPSCAN - Read events from a partition
  • ESUB - Subscribe to events in real-time