Skip to content

GriffinCanCode/clearcache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ClearCache - High-Performance Development Cache Cleaner

Rust License: Griffin

ClearCache is a high-performance cache clearing system designed specifically for development environments. Built in Rust, it provides safe, efficient, and comprehensive cache management across multiple development ecosystems including Node.js, Rust, Go, Python, Docker, and general build artifacts.

Important: ClearCache ignores .gitignore files by default since cache directories (like target/, node_modules/, __pycache__/) are often in .gitignore but should still be cleaned. Use --respect-gitignore if you want to honor .gitignore patterns.

Why ClearCache

Development environments accumulate substantial cache data over time. Node.js projects can generate gigabytes in node_modules, Rust projects create large target directories, and various build tools leave behind temporary files. Manual cleanup is time-consuming and error-prone. ClearCache solves this by providing automated, safe, and extremely fast cache management.

The system was architected to address performance limitations found in existing solutions. Through comprehensive benchmarking against Python, Go, and shell-based alternatives, ClearCache demonstrates 2-5x performance improvements while maintaining strict safety guarantees.

Core Capabilities

High-Performance Architecture: Rust-based implementation with parallel processing that scales across CPU cores. Efficient memory management and optimized file system operations deliver superior performance compared to interpreted alternatives.

Comprehensive Ecosystem Support: Native support for Node.js, Rust, Go, Python, Docker, and general development caches. Extensible pattern matching system allows for precise targeting of cache artifacts without affecting source code or configuration files.

Safety-First Design: Multiple validation layers prevent accidental deletion of critical system files or important project artifacts. Intelligent path analysis and content validation ensure only genuine cache data is targeted.

Flexible Operation Modes: Dry-run capabilities for safe preview, selective cache type targeting, recursive directory processing, and detailed reporting provide complete operational control.

Zero-Dependency Deployment: Single binary distribution with automatic symbolic link installation for global accessibility across development environments.

Supported Cache Types

Node.js Ecosystem

  • node_modules - Dependencies
  • .npm - NPM cache
  • .next - Next.js build cache
  • .nuxt - Nuxt.js build cache
  • .output - Nuxt.js output
  • .yarn/cache - Yarn cache
  • .pnpm-store - PNPM cache
  • .turbo - Turbo build cache
  • .parcel-cache - Parcel build cache

Rust Ecosystem

  • target - Cargo build artifacts
  • Cargo.lock - Lock files (with safety checks)

Go Ecosystem

  • go-build - Go build cache
  • pkg/mod - Go module cache

Python Ecosystem

  • __pycache__ - Python bytecode cache
  • *.pyc, *.pyo - Python bytecode files
  • .pytest_cache - Pytest cache
  • .mypy_cache - MyPy cache
  • .pip - Pip cache

Docker

  • System cache (containers, images, volumes)
  • Build cache

General

  • .cache, cache, @cache - General cache directories
  • .temp, temp, @temp, .tmp, tmp - Temporary directories
  • build, dist, out, .build - Build output directories
  • *.log, logs, .log - Log files and directories

Installation

Prerequisites

Quick Install

git clone <repository-url>
cd clearcache
./install.sh

The installation script will:

  1. Build the project in release mode
  2. Create a symbolic link in your PATH
  3. Make the clearcache command available globally

Manual Installation

cargo build --release
cp target/release/clearcache ~/.local/bin/
# or
cp target/release/clearcache /usr/local/bin/

Usage

Basic Usage

# Clean current directory (safe caches only)
clearcache

# Clean specific directory (safe caches only)
clearcache /path/to/project

# Clean recursively (all subdirectories)
clearcache --recursive

# Dry run (show what would be deleted)
clearcache --dry-run

# Include libraries/dependencies (requires reinstallation)
clearcache --include-libraries

Safe vs Library Cleaning

Safe Mode (Default): Cleans temporary caches that don't require reinstallation:

  • Python: __pycache__, .pytest_cache, .mypy_cache, bytecode files
  • Node.js: .npm, .next, .nuxt, .turbo, .parcel-cache
  • Rust: Cargo.lock (in some cases)
  • Go: go-build cache
  • General: build outputs, temp files, logs

Library Mode (--include-libraries): Additionally cleans dependencies requiring reinstallation:

  • Node.js: node_modules
  • Rust: target directories
  • Go: pkg/mod module cache

Advanced Usage

# Clean only specific cache types (safe mode)
clearcache --types node,rust
clearcache --types python,docker

# Clean with libraries included
clearcache --include-libraries --types node,rust

# Clean with verbose output
clearcache --verbose

# Clean with custom thread count
clearcache --parallel 16

# Combine options
clearcache --recursive --dry-run --verbose --types node,rust --include-libraries

Cache Types

Available cache types:

  • node (or nodejs, npm, yarn, pnpm)
  • rust (or cargo)
  • go (or golang)
  • python (or py, pip)
  • docker
  • general (or cache)
  • all (default - includes everything)

Command Line Options

USAGE:
    clearcache [OPTIONS] [DIRECTORY]

ARGS:
    <DIRECTORY>    Directory to clean (default: current directory)

OPTIONS:
    -n, --dry-run              Show what would be deleted without actually deleting
    -r, --recursive            Recursively clean all subdirectories
    -t, --types <TYPES>        Comma-separated list of cache types to clean [default: all]
    -l, --include-libraries    Include libraries/dependencies that require reinstallation
    -p, --parallel <NUM>       Number of parallel threads (default: CPU count)
    -v, --verbose              Verbose output
    -f, --force                Force deletion without confirmation
        --respect-gitignore    Respect .gitignore files (by default, .gitignore is ignored)
        --no-ignore            Ignore .clearcacheignore files
    -h, --help                 Print help information
    -V, --version              Print version information

Performance Characteristics

Based on comprehensive benchmarks, this Rust implementation significantly outperforms alternatives:

  • 2-3x faster than Go implementations
  • 4-5x faster than Python implementations
  • Comparable to C implementations while being memory-safe
  • Parallel processing scales with CPU cores
  • Efficient memory usage with minimal allocations

Safety Features

  • System Path Protection: Prevents deletion of critical system directories
  • Important File Detection: Skips directories containing important project files
  • Intelligent Git Integration: By default ignores .gitignore files since cache directories are often excluded from version control but should still be cleaned. Use --respect-gitignore to honor .gitignore patterns.
  • Path Validation: Multiple checks to ensure safe deletion
  • Dry Run Mode: Always test before actual deletion
  • Depth Limiting: Prevents infinite recursion

Example Output

Safe Mode (Default)

🧹 ClearCache - Extremely Efficient Cache Cleaner
Directory: /Users/dev/projects
Cache types: Node, Rust, Go, Python, Docker, General
Threads: 16
πŸ”’ SAFE MODE - Only cleaning temporary caches (use --include-libraries for full clean)

β ‹ Scanning directories...
Found 15 cache items to clean

  Deleted: /Users/dev/project1/.next (234 files, 15.2 MB)
  Deleted: /Users/dev/project2/__pycache__ (12 files, 2.1 MB)
  Deleted: /Users/dev/project3/.pytest_cache (45 files, 8.3 MB)

πŸ“Š Summary
Files processed: 291
Space freed: 25.6 MB
Directories cleaned: 15
βœ… All operations completed successfully!

Library Mode (--include-libraries)

🧹 ClearCache - Extremely Efficient Cache Cleaner
Directory: /Users/dev/projects
Cache types: Node, Rust, Go, Python, Docker, General
Threads: 16
πŸ“¦ LIBRARY MODE - Including dependencies that require reinstallation

β ‹ Scanning directories...
Found 23 cache items to clean

  Deleted: /Users/dev/project1/node_modules [LIBRARY] (1,234 files, 45.2 MB)
  Deleted: /Users/dev/project2/target [LIBRARY] (567 files, 123.4 MB)  
  Deleted: /Users/dev/project3/__pycache__ (12 files, 2.1 MB)

πŸ“Š Summary
Files processed: 1,813
Space freed: 170.7 MB
Directories cleaned: 23
βœ… All operations completed successfully!

Error Handling

The system includes comprehensive error handling:

  • Permission Errors: Gracefully handles insufficient permissions
  • Path Errors: Validates all paths before operations
  • Concurrent Access: Handles files being modified during cleaning
  • Partial Failures: Continues cleaning even if some operations fail
  • Detailed Reporting: Shows exactly what succeeded and what failed

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Setup

git clone <repository-url>
cd clearcache
cargo build
cargo test

Adding New Cache Types

  1. Add patterns to src/cache_types.rs
  2. Update the documentation
  3. Add tests
  4. Submit a PR

License

This project is licensed under the Griffin License - see the LICENSE file for details.

Acknowledgments

  • Inspired by various cache cleaning tools in the community
  • Built with the amazing Rust ecosystem
  • Performance insights from benchmarking research

Related Projects

Documentation

For detailed technical documentation, architecture details, and implementation notes, see the docs/ directory.


Built with Rust for Performance and Safety

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors