Skip to main content

Module entity_key

Module entity_key 

Source
Expand description

Type-safe entity keys for entity-level cache invalidation.

An EntityKey represents a specific entity instance, combining:

  • entity_type: The type of entity (e.g., “User”, “Post”, “Comment”)
  • entity_id: The unique identifier (UUID) of that instance

Entity keys are used to track which queries depend on which specific entities, enabling precise invalidation when those entities are modified.

§Format

Entity keys are serialized as: "EntityType:uuid"

Example:

"User:550e8400-e29b-41d4-a716-446655440000"
"Post:e7d7a1a1-b2c3-4d5e-f6g7-h8i9j0k1l2m3"

§Examples

use fraiseql_core::cache::EntityKey;

let key = EntityKey::new("User", "550e8400-e29b-41d4-a716-446655440000").unwrap();
assert_eq!(key.to_cache_key(), "User:550e8400-e29b-41d4-a716-446655440000");

Structs§

EntityKey
Type-safe entity key for cache invalidation.