Add Valkey/Redis cache visualization and API autoloading for graphical inspection

This commit is contained in:
2026-01-01 06:48:52 +00:00
parent 218a15a4c2
commit 6dea66b0cf
8 changed files with 565 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
// Simple Express API to serve all Redis/Valkey cache keys and values as JSON (CommonJS)
const express = require('express');
const Redis = require('ioredis');
const app = express();
const redis = new Redis({
host: process.env.REDIS_HOST || '127.0.0.1',
port: Number(process.env.REDIS_PORT || 6379),
password: process.env.REDIS_PASSWORD,
});
app.get('/api/cache', async (req, res) => {
try {
const keys = await redis.keys('*');
const result = [];
for (const key of keys) {
let value = await redis.get(key);
try { value = JSON.parse(value); } catch {}
result.push({ key, value });
}
res.json(result);
} catch (err) {
res.status(500).json({ error: err.message });
}
});
const port = process.env.CACHE_API_PORT || 3006;
app.listen(port, () => {
console.log(`Cache API running on http://localhost:${port}/api/cache`);
});