← ClaudeAtlas

cassandra-patternslisted

When to activate: Cassandra, CQL, partition key, wide row, Cassandra cluster, eventual consistency, Scylla
Mattakushi432/Claude-Code-Skills-Custom-DevTools-Pack · ★ 0 · AI & Automation · score 73
Install: claude install-skill Mattakushi432/Claude-Code-Skills-Custom-DevTools-Pack
# Cassandra Patterns ## Data Modeling — Query-First Design ```cql -- Design tables around access patterns, NOT entities -- Access pattern: "Get all messages for a conversation, ordered by time" CREATE TABLE messages_by_conversation ( conversation_id UUID, sent_at TIMEUUID, -- time-ordered UUID for clustering sender_id UUID, body TEXT, is_deleted BOOLEAN, PRIMARY KEY (conversation_id, sent_at) ) WITH CLUSTERING ORDER BY (sent_at DESC) AND compaction = {'class': 'TimeWindowCompactionStrategy', 'compaction_window_size': '1', 'compaction_window_unit': 'DAYS'}; -- Access pattern: "Get user profile by user_id" CREATE TABLE users ( user_id UUID PRIMARY KEY, name TEXT, email TEXT, settings MAP<TEXT, TEXT> ); -- Access pattern: "Find user by email" — denormalize! CREATE TABLE users_by_email ( email TEXT PRIMARY KEY, user_id UUID, name TEXT ); ``` ## Partition Key Design ```cql -- BAD: low cardinality partition key → hot partition CREATE TABLE events (day DATE, time TIMEUUID, data TEXT, PRIMARY KEY (day, time)); -- all events on same day → one node -- GOOD: add bucket to distribute load CREATE TABLE events ( day DATE, bucket INT, -- hash(user_id) % 100 time TIMEUUID, data TEXT, PRIMARY KEY ((day, bucket), time) ) WITH CLUSTERING ORDER BY (time DESC); -- Composite partition key prevents single-node hotspot CREATE TABLE sensor_data (