cassandra
БесплатноБез исполняемых скриптовНе проверенApache Cassandra is a distributed NoSQL database designed for high availability and linear scalability. Learn CQL (Cassandra Query Language), data modeling…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Cassandra
Overview
Apache Cassandra is a peer-to-peer distributed database that provides high availability with no single point of failure. Data is distributed across nodes using consistent hashing.
Instructions
Installation
# Docker: current stable line is 5.0 (5.0.9 on 2026-10-24); bind to localhost only
docker run -d --name cassandra -p 127.0.0.1:9042:9042 cassandra:5.0
# Startup takes about a minute; retry until this prints the cqlsh/Cassandra versions
docker exec -it cassandra cqlsh -e "show version"
# Node.js driver
npm install cassandra-driver
# Python driver
pip install cassandra-driver
CQL Basics
-- keyspace.cql: Create keyspace with replication strategy
CREATE KEYSPACE IF NOT EXISTS myapp
WITH replication = {
'class': 'NetworkTopologyStrategy',
'datacenter1': 1
}
AND durable_writes = true;
USE myapp;
The replication factor must not exceed the number of nodes you can reach. With one Docker node, 'datacenter1': 3 is accepted (with a warning) but every QUORUM or LOCAL_QUORUM request then fails with "Cannot achieve consistency level" (verified on 5.0.9). Use 1 for a single node and 3 per datacenter in production. Check the datacenter name with nodetool status; the Docker image uses datacenter1.
Data Modeling
-- tables.cql: Design tables around query patterns (partition key + clustering key)
-- Rule: one table per query pattern
-- Users by email (partition key: email)
CREATE TABLE users (
email text PRIMARY KEY,
name text,
created_at timestamp
);
-- Posts by user, ordered by time (partition: user_id, clustering: created_at DESC)
CREATE TABLE posts_by_user (
user_id uuid,
created_at timestamp,
post_id uuid,
title text,
body text,
PRIMARY KEY (user_id, created_at)
) WITH CLUSTERING ORDER BY (created_at DESC);
-- Support tables used by the batch examples below
CREATE TABLE user_post_counts (user_id uuid PRIMARY KEY, post_count int);
CREATE TABLE user_stats (user_id uuid PRIMARY KEY, post_count counter);
-- Time-series: sensor readings bucketed by day
CREATE TABLE sensor_readings (
sensor_id text,
day text,
reading_time timestamp,
value double,
PRIMARY KEY ((sensor_id, day), reading_time)
) WITH CLUSTERING ORDER BY (reading_time DESC);
CRUD Operations
-- crud.cql: Basic insert, select, update, delete
INSERT INTO users (email, name, created_at)
VALUES ('[email protected]', 'Alice', toTimestamp(now()));
SELECT * FROM users WHERE email = '[email protected]';
-- Query with partition and clustering key
SELECT * FROM posts_by_user
WHERE user_id = 550e8400-e29b-41d4-a716-446655440000
AND created_at > '2026-01-01'
LIMIT 20;
UPDATE users SET name = 'Alice Smith' WHERE email = '[email protected]';
DELETE FROM users WHERE email = '[email protected]';
-- Logged batch: all-or-nothing across tables, for keeping denormalized copies in step.
-- Not a performance tool; keep it to a few statements. Counter updates cannot be mixed in
-- (rejected: "Counter and non-counter mutations cannot exist in the same batch").
BEGIN BATCH
INSERT INTO posts_by_user (user_id, created_at, post_id, title)
VALUES (550e8400-e29b-41d4-a716-446655440000, toTimestamp(now()), uuid(), 'Hello');
UPDATE user_post_counts SET post_count = 1 WHERE user_id = 550e8400-e29b-41d4-a716-446655440000;
APPLY BATCH;
-- Counters live in their own table and their own batch type
BEGIN COUNTER BATCH
UPDATE user_stats SET post_count = post_count + 1 WHERE user_id = 550e8400-e29b-41d4-a716-446655440000;
APPLY BATCH;
Node.js Driver
// db.js: Cassandra client with DataStax Node.js driver
const { Client, types } = require('cassandra-driver');
const client = new Client({
contactPoints: ['127.0.0.1:9042'],
localDataCenter: 'datacenter1',
keyspace: 'myapp',
queryOptions: { consistency: types.consistencies.localQuorum },
});
async function main() {
await client.connect();
// Insert
await client.execute(
'INSERT INTO users (email, name, created_at) VALUES (?, ?, ?)',
['[email protected]', 'Bob', new Date()],
{ prepare: true }
);
// Query
const result = await client.execute(
'SELECT * FROM users WHERE email = ?',
['[email protected]'],
{ prepare: true }
);
console.log(result.rows[0]);
// Stream every row of one partition (the driver pages internally)
const userId = types.Uuid.fromString('550e8400-e29b-41d4-a716-446655440000');
const query = 'SELECT * FROM posts_by_user WHERE user_id = ?';
for await (const row of client.stream(query, [userId], { prepare: true })) {
console.log(row.title);
}
// Manual paging: one page per call, pass result.pageState back to continue
const page = await client.execute(query, [userId], { prepare: true, fetchSize: 20 });
const next = page.pageState; // undefined when there are no more pages
await client.shutdown();
}
main().catch(console.error);
Python Dri
Установить cassandra в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл cassandra?
Apache Cassandra is a distributed NoSQL database designed for high availability and linear scalability. Learn CQL (Cassandra Query Language), data modeling with partition keys, replication strategies, and integration with Node.js using the DataStax driver.
Как установить скилл cassandra?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cassandra запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic