Skip to content

v0.6.0 - SQLite Cache for DuckDB Queryability

Choose a tag to compare

@jedarden jedarden released this 05 Dec 07:45

What's New

SQLite-based Token Cache

Complete rewrite of the token caching system for better queryability:

  • Cache stored in .ccdash/tokens.db SQLite database with WAL mode
  • Directly queryable by DuckDB, SQLite CLI, or any SQLite-compatible tool
  • Schema: token_events table with timestamp indexes, file_state for tracking
  • Batch insertions for improved performance

Incremental Ingestion

Smart processing of JSONL files:

  • Tracks last processed line per file to avoid reprocessing
  • Automatic file invalidation on modification or truncation
  • Deduplication via unique index on (source_file, line_number)

SQL-based Lookback Queries

Efficient time-range filtering:

  • Uses indexed timestamp_unix column for fast range queries
  • Per-model aggregation computed directly in SQL
  • Recent events query for rate calculations

Build-time Version Injection

  • Version now injected at build time via ldflags
  • Use make release VERSION=vX.X.X for release builds
  • Self-updater now works correctly across versions

Breaking Changes

  • Cache file changed from .ccdash/token_cache.json to .ccdash/tokens.db
  • Old JSON caches will not be migrated (will rebuild from JSONL files on first run)

Technical Details

  • Uses modernc.org/sqlite pure Go library (no CGO required)
  • Cross-platform binaries without C compiler dependencies
  • SQLite configured with WAL journal mode and NORMAL synchronous

Installation

```bash

Linux (x64)

curl -LO https://github.com/jedarden/ccdash/releases/download/v0.6.0/ccdash-linux-amd64
chmod +x ccdash-linux-amd64

Linux (ARM64)

curl -LO https://github.com/jedarden/ccdash/releases/download/v0.6.0/ccdash-linux-arm64
chmod +x ccdash-linux-arm64

macOS (Intel)

curl -LO https://github.com/jedarden/ccdash/releases/download/v0.6.0/ccdash-darwin-amd64
chmod +x ccdash-darwin-amd64

macOS (Apple Silicon)

curl -LO https://github.com/jedarden/ccdash/releases/download/v0.6.0/ccdash-darwin-arm64
chmod +x ccdash-darwin-arm64
```

Querying the SQLite Cache

```bash

Using sqlite3

sqlite3 .ccdash/tokens.db "SELECT model, SUM(input_tokens + output_tokens) as total FROM token_events GROUP BY model"

Using DuckDB

duckdb -c "ATTACH '.ccdash/tokens.db' AS cc; SELECT * FROM cc.token_events WHERE timestamp_unix > strftime('%s', 'now') - 86400"
```

Full Changelog: v0.5.0...v0.6.0