Skip to content

Garbage Collection

Managing cache storage with garbage collection.

Running GC

rninja -t cache-gc

What Gets Cleaned

  • Entries older than max_age
  • Oldest entries when exceeding max_size
  • Orphaned blob files
  • Corrupt entries

Scheduling GC

Cron

# Weekly cleanup
0 0 * * 0 rninja -t cache-gc

Systemd Timer

# /etc/systemd/system/rninja-gc.timer
[Unit]
Description=rninja GC Timer

[Timer]
OnCalendar=weekly
Persistent=true

[Install]
WantedBy=timers.target
# /etc/systemd/system/rninja-gc.service
[Unit]
Description=rninja Garbage Collection

[Service]
Type=oneshot
ExecStart=/usr/local/bin/rninja -t cache-gc

Aggressive Cleanup

# Reduce to 1GB
RNINJA_CACHE_MAX_SIZE=1G rninja -t cache-gc

Monitoring GC

# Before
rninja -t cache-stats

# Run GC
rninja -t cache-gc

# After
rninja -t cache-stats