A zero-dependency Golang CLI to manage all caches in your Medusa v2 + Next.js project from one place.
| Cache | Location |
|---|---|
| Redis | Medusa v2 Docker Redis (TCP) |
| Next.js | .next/cache/ directory |
| Node modules | node_modules/.cache/, .turbo/ |
| CDN/Browser | Info only (clear via your CDN provider) |
cd medusa-cache-cli
# Build binary
go build -o medusa-cache-cli .
# Install system-wide (Linux/Mac)
sudo mv medusa-cache-cli /usr/local/bin/
# Or use Makefile
make build
make installCopy the example env file and adjust to your setup:
cp .env.example .env# Redis — your docker-compose maps 6380:6379, so from host use localhost:6380
REDIS_URL=localhost:6380
REDIS_PASSWORD=
# Paths to your projects (relative or absolute)
NEXTJS_DIR=../storefront
MEDUSA_DIR=../backend# All caches
medusa-cache-cli status
# Specific target
medusa-cache-cli status --target redis
medusa-cache-cli status --target nextjs
medusa-cache-cli status --target node
medusa-cache-cli status --target cdn# Clear all (asks for confirmation)
medusa-cache-cli clear
# Clear all without confirmation
medusa-cache-cli clear --yes
# Clear specific cache
medusa-cache-cli clear --target redis --yes
medusa-cache-cli clear --target nextjs --yes
medusa-cache-cli clear --target node --yesmedusa-cache-cli status --env /path/to/custom.env
medusa-cache-cli clear --env /path/to/custom.env --yesInstead of typing the full command with --env every time, add an alias or function to your shell.
Add to ~/.bashrc or ~/.zshrc:
alias mcc="medusa-cache-cli --env /root/node-sunnah/sfu-backend/medusa-cache-cli/.env"Reload:
source ~/.bashrcUsage:
mcc status
mcc clear --yesAdd to ~/.bashrc or ~/.zshrc:
mcc() {
cmd="$1"
if [ -z "$cmd" ]; then
echo "Usage: mcc <command> [flags]" >&2
return 1
fi
shift
medusa-cache-cli "$cmd" --env /root/node-sunnah/sfu-backend/medusa-cache-cli/.env "$@"
}Reload:
source ~/.bashrcUsage:
mcc status
mcc status --target redis
mcc clear --yes
mcc clear --target nextjs --yesThe function version is recommended — it correctly handles extra flags like
--targetand--yes.
Your Redis setup:
redis:
image: redis:7-alpine
ports:
- "6380:6379" # host port 6380 → container port 6379So in .env use:
REDIS_URL=localhost:6380The CLI also understands the redis:// URL format used inside Docker:
REDIS_URL=redis://redis:6379 # works toomedusa-cache-cli/
├── main.go
├── cmd/
│ └── root.go # CLI entry — status, clear commands
├── internal/
│ ├── cache/
│ │ └── cache.go # Redis flush, Next.js & node cache removal
│ ├── config/
│ │ └── config.go # .env loader + Redis URL parser
│ ├── redis/
│ │ └── client.go # Raw TCP Redis client (RESP protocol, no deps)
│ └── ui/
│ └── ui.go # ANSI color terminal output
├── .env.example
├── Makefile
└── go.mod
Zero external dependencies — only Go standard library is used.