Skip to content

Conversation

@ghinks
Copy link
Owner

@ghinks ghinks commented Oct 19, 2025

Summary

Refactor the SQLite cache system to eliminate string-based cache keys and replace them with type-specific methods that accept primary key components directly.

Changes

Removed string-based cache key system:

  • Deleted cache_keys.py - no longer needed
  • Removed _parse_cache_key() method that parsed string keys
  • Removed _get_table_name() method for key-to-table mapping
  • Removed generic get(key), set(key, ...), delete(key) methods
  • Removed list_keys() method
  • Removed cache key format constants

Added type-specific methods to SQLiteCache:

PR Review cache:

  • get_pr_review(owner, repo, pull_number) → Returns cached review data
  • set_pr_review(owner, repo, pull_number, data, ...) → Stores review data
  • delete_pr_review(owner, repo, pull_number) → Deletes review entry

PR Metadata cache:

  • get_pr_metadata(owner, repo, pr_number) → Returns cached PR metadata
  • set_pr_metadata(owner, repo, pr_number, data, ...) → Stores PR metadata
  • delete_pr_metadata(owner, repo, pr_number) → Deletes PR metadata

PR Index cache:

  • get_pr_index(owner, repo) → Returns cached PR index
  • set_pr_index(owner, repo, data, ...) → Stores PR index
  • delete_pr_index(owner, repo) → Deletes PR index

Updated CacheManager:

  • Removed imports of key generation functions
  • Updated all methods to call type-specific SQLiteCache methods directly
  • No more cache key string construction

Benefits

Type-safe API - Explicit parameters with proper types instead of string keys
No parsing overhead - Direct parameter usage, no string splitting/validation
Clearer method signatures - Self-documenting what each method does
Better IDE support - Autocomplete and type checking work perfectly
Simpler code - Removed ~200 lines of key parsing logic
More maintainable - Changes to primary keys are compiler-checked

Test Plan

  • All 60 tests passing
  • Ruff linting passed
  • Mypy type checking passed (24 source files)
  • Cache functionality verified across all three cache types
  • No breaking changes - CacheManager API unchanged

🤖 Generated with Claude Code

Replace the string-based cache key system with type-specific methods that accept
primary key components directly, improving type safety and code clarity.

**Removed:**
- String cache key parsing logic (_parse_cache_key, _get_table_name)
- Generic get/set/delete methods that accepted string keys
- list_keys() method
- cache_keys.py file with key generation functions
- Cache key format constants

**Added type-specific methods:**
- PR Review: get_pr_review(), set_pr_review(), delete_pr_review()
- PR Metadata: get_pr_metadata(), set_pr_metadata(), delete_pr_metadata()
- PR Index: get_pr_index(), set_pr_index(), delete_pr_index()

**Benefits:**
- Type-safe API with explicit parameters
- No string parsing overhead
- Better IDE autocomplete and type checking
- Simpler, more maintainable code (~200 lines removed)
- Compiler-checked changes to primary keys

All tests passing (60/60), ruff and mypy checks passed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@ghinks ghinks merged commit ec2d8f3 into main Oct 19, 2025
9 checks passed
@ghinks ghinks deleted the feat/table-refactoring-pr-metadata branch October 19, 2025 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants