Skip to content

Instantly share code, notes, and snippets.

@Narrator
Last active February 6, 2026 18:29
Show Gist options
  • Select an option

  • Save Narrator/8c81db5b3c7e46359107e7d605a68c95 to your computer and use it in GitHub Desktop.

Select an option

Save Narrator/8c81db5b3c7e46359107e7d605a68c95 to your computer and use it in GitHub Desktop.
Locality in rust
// Local: in-memory HashMap — fast, not resilient
let sessions: HashMap<SessionId, Session> = HashMap::new();
// Server restart = all sessions lost
// Distributed: Redis cluster — slower, resilient
let session = redis.get(session_id).await?;
// Network hop, but survives server restarts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment