Self-Healing Database Proxy — Transparent MySQL caching with Redis. Zero code changes.
1.8K
A high-performance, transparent database proxy that sits between your application and MySQL. It automatically caches SELECT queries in Redis and intelligently invalidates caches on INSERT, UPDATE, and DELETE — with zero code changes in your application.
Built with PHP 8.2+ and ReactPHP for non-blocking, asynchronous I/O.
3306 to 4000docker pull mdishtiaque/sql-shield:latest
Choose the method that matches your operating system:
docker run -d \
--name sql-shield \
--network host \
-e REAL_DB_HOST=127.0.0.1 \
-e REAL_DB_PORT=3306 \
-e REDIS_HOST=127.0.0.1 \
-e REDIS_PORT=6379 \
mdishtiaque/sql-shield:latest
--network host gives the container direct access to your machine's network. No port mapping needed — the proxy is available at localhost:4000 and the dashboard at localhost:8080.
docker run -d \
--name sql-shield \
-p 4000:4000 \
-p 8080:8080 \
-e REAL_DB_HOST=host.docker.internal \
-e REAL_DB_PORT=3306 \
-e REDIS_HOST=host.docker.internal \
-e REDIS_PORT=6379 \
mdishtiaque/sql-shield:latest
host.docker.internal is a special DNS name that points to your host machine from inside the container. This works automatically on Docker Desktop for Mac and Windows.
If your MySQL and Redis are on separate servers (e.g., AWS RDS, Redis Cloud):
docker run -d \
--name sql-shield \
-p 4000:4000 \
-p 8080:8080 \
-e REAL_DB_HOST=your-db-server.example.com \
-e REAL_DB_PORT=3306 \
-e REDIS_HOST=your-redis-server.example.com \
-e REDIS_PORT=6379 \
mdishtiaque/sql-shield:latest
Replace the hostnames with your actual database and Redis server addresses.
# Check logs — you should see "TRIAL (7 days left)" and "Proxy listening"
docker logs sql-shield
# Test proxy connection
mysql -h 127.0.0.1 -P 4000 -u your_user -p
# Open the dashboard in your browser
# http://localhost:8080
In your application's database config, change the port from 3306 to 4000. That's it.
Laravel .env example:
DB_HOST=127.0.0.1
DB_PORT=4000
WordPress wp-config.php example:
define('DB_HOST', '127.0.0.1:4000');
Node.js example:
const connection = mysql.createConnection({
host: '127.0.0.1',
port: 4000,
user: 'your_user',
password: 'your_password',
database: 'your_db'
});
No other code changes needed. SQL-Shield works transparently with any MySQL client.
SQL-Shield includes a 7-day free trial that starts automatically when you first run the container — no license key required.
After the trial, you'll need a license key to continue using SQL-Shield. Purchase one at sql-shield.dev/pricing.
docker run -d \
--name sql-shield \
--network host \
-e REAL_DB_HOST=127.0.0.1 \
-e REAL_DB_PORT=3306 \
-e REDIS_HOST=127.0.0.1 \
-e REDIS_PORT=6379 \
-e LICENSE_KEY="your-license-key-here" \
mdishtiaque/sql-shield:latest
You'll receive your license key via email within 10 minutes of purchase.
# Stop the proxy
docker stop sql-shield
# Start it again
docker start sql-shield
# Restart
docker restart sql-shield
# View live logs
docker logs -f sql-shield
# Remove completely
docker rm -f sql-shield
| Variable | Default | Description |
|---|---|---|
REAL_DB_HOST | 127.0.0.1 | Your MySQL server host |
REAL_DB_PORT | 3306 | Your MySQL server port |
REDIS_HOST | 127.0.0.1 | Your Redis server host |
REDIS_PORT | 6379 | Your Redis server port |
PROXY_HOST | 0.0.0.0 | Address the proxy listens on |
PROXY_PORT | 4000 | Port the proxy listens on |
LICENSE_KEY | (empty) | Your license key (empty = 7-day trial) |
| Port | Service |
|---|---|
| 4000 | SQL-Shield Proxy — your app connects here instead of MySQL |
| 8080 | Dashboard — real-time monitoring web UI |
Your App (:4000) ──► SQL-Shield Proxy ──► MySQL (:3306)
│
▼
Redis Cache
SELECT queries — Checked against Redis first. On cache HIT, the response is served directly from Redis (~0.3ms). On MISS, the query goes to MySQL, and the response is cached for future requests.
INSERT / UPDATE / DELETE — Forwarded to MySQL immediately, then SQL-Shield invalidates all cached queries related to the affected table(s).
Ignored queries — FOR UPDATE, FOR SHARE, Laravel Telescope tables, and prepared statements are passed through without caching.
Access the enterprise monitoring dashboard at http://localhost:8080:
For best caching performance with Laravel, enable emulated prepares in config/database.php:
'mysql' => [
// ... existing config
'options' => [
PDO::ATTR_EMULATE_PREPARES => true,
],
],
This ensures SQL-Shield can intercept and cache all queries (including those using prepared statements).
For a complete setup with MySQL, Redis, and SQL-Shield all in one:
services:
sql-shield:
image: mdishtiaque/sql-shield:latest
ports:
- "4000:4000"
- "8080:8080"
environment:
REAL_DB_HOST: mysql
REAL_DB_PORT: "3306"
REDIS_HOST: redis
REDIS_PORT: "6379"
LICENSE_KEY: "${LICENSE_KEY:-}"
depends_on:
- mysql
- redis
mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: myapp
ports:
- "3306:3306"
redis:
image: redis:7-alpine
ports:
- "6379:6379"
Run with: docker compose up -d
Your app connects to localhost:4000 instead of localhost:3306. Everything else stays the same.
Proprietary. All rights reserved.
Content type
Image
Digest
sha256:b470f5d2b…
Size
55.1 MB
Last updated
8 months ago
docker pull mdishtiaque/sql-shield