http://localhost:9080 # Node 1
http://localhost:9081 # Node 2
http://localhost:9082 # Node 3
Currently no authentication required. All endpoints are publicly accessible.
Retrieve a value from the cache.
Endpoint: GET /api/cache/{key}
Parameters:
key(path): The cache key to retrieve
Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"key": "mykey",
"value": "myvalue",
"ttl_remaining": "3540s",
"node": "node-1",
"correlation_id": "uuid-here"
}Error Response:
HTTP/1.1 404 Not Found
Content-Type: application/json
{
"error": "Key not found",
"key": "nonexistent",
"correlation_id": "uuid-here"
}Example:
curl -X GET http://localhost:9080/api/cache/mykeySet a key-value pair in the cache with optional TTL.
Endpoint: PUT /api/cache/{key}
Parameters:
key(path): The cache key to set
Request Body:
{
"value": "string",
"ttl_hours": 1.0 // Optional, defaults to 1 hour
}Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"key": "mykey",
"value": "myvalue",
"ttl_hours": 1.0,
"replicated": true,
"node": "node-1",
"correlation_id": "uuid-here"
}Example:
curl -X PUT http://localhost:9080/api/cache/mykey \
-H "Content-Type: application/json" \
-d '{"value": "Hello World", "ttl_hours": 2.0}'Remove a key from the cache.
Endpoint: DELETE /api/cache/{key}
Parameters:
key(path): The cache key to delete
Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"key": "mykey",
"deleted": true,
"replicated": true,
"node": "node-1",
"correlation_id": "uuid-here"
}Error Response:
HTTP/1.1 404 Not Found
Content-Type: application/json
{
"error": "Key not found",
"key": "nonexistent",
"correlation_id": "uuid-here"
}Example:
curl -X DELETE http://localhost:9080/api/cache/mykeyCheck if the node is healthy and operational.
Endpoint: GET /health
Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"healthy": true,
"node": "node-1",
"cluster_size": 3,
"correlation_id": "uuid-here"
}Example:
curl -X GET http://localhost:9080/healthGet detailed information about the cluster state.
Endpoint: GET /api/cluster/status
Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"cluster_name": "hypercache",
"node_id": "node-1",
"cluster_size": 3,
"nodes": [
{
"id": "node-1",
"address": "127.0.0.1:7946",
"status": "alive",
"role": "active"
},
{
"id": "node-2",
"address": "127.0.0.1:7947",
"status": "alive",
"role": "active"
},
{
"id": "node-3",
"address": "127.0.0.1:7948",
"status": "alive",
"role": "active"
}
],
"replication_factor": 3,
"consistency_level": "eventual",
"correlation_id": "uuid-here"
}Example:
curl -X GET http://localhost:9080/api/cluster/statusGet performance metrics for this node.
Endpoint: GET /api/node/metrics
Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"node_id": "node-1",
"uptime": "2h34m12s",
"cache_stats": {
"total_keys": 1523,
"memory_usage": "45.2MB",
"hit_rate": 0.847,
"operations_per_second": 234.5
},
"replication_stats": {
"events_published": 156,
"events_received": 312,
"replication_lag_avg": "12ms"
},
"persistence_stats": {
"aof_size": "12.3MB",
"last_snapshot": "2025-08-21T17:30:00Z",
"recovery_time": "340ms"
},
"filter_stats": {
"false_positive_rate": 0.008,
"filter_size": "2.1MB",
"total_insertions": 1523,
"total_lookups": 8745
},
"correlation_id": "uuid-here"
}Example:
curl -X GET http://localhost:9080/api/node/metricsRetrieve current node configuration (read-only).
Endpoint: GET /api/config
Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"node": {
"id": "node-1",
"data_dir": "/tmp/hypercache/node-1"
},
"network": {
"resp_port": 8080,
"http_port": 9080,
"gossip_port": 7946
},
"cluster": {
"seeds": ["127.0.0.1:7946", "127.0.0.1:7947", "127.0.0.1:7948"],
"replication_factor": 3,
"consistency_level": "eventual"
},
"cache": {
"max_memory": "8GB",
"default_ttl": "1h",
"cuckoo_filter_fpp": 0.01
},
"correlation_id": "uuid-here"
}Example:
curl -X GET http://localhost:9080/api/configRetrieve multiple keys in a single request.
Endpoint: POST /api/cache/batch/get
Request Body:
{
"keys": ["key1", "key2", "key3", "key4"]
}Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"results": [
{
"key": "key1",
"value": "value1",
"found": true,
"ttl_remaining": "3540s"
},
{
"key": "key2",
"found": false,
"error": "Key not found"
},
{
"key": "key3",
"value": "value3",
"found": true,
"ttl_remaining": "1800s"
}
],
"node": "node-1",
"total_requested": 3,
"total_found": 2,
"correlation_id": "uuid-here"
}Example:
curl -X POST http://localhost:9080/api/cache/batch/get \
-H "Content-Type: application/json" \
-d '{"keys": ["key1", "key2", "key3"]}'Set multiple key-value pairs in a single request.
Endpoint: POST /api/cache/batch/set
Request Body:
{
"items": [
{
"key": "key1",
"value": "value1",
"ttl_hours": 2.0
},
{
"key": "key2",
"value": "value2",
"ttl_hours": 1.0
}
]
}Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"results": [
{
"key": "key1",
"success": true,
"replicated": true
},
{
"key": "key2",
"success": true,
"replicated": true
}
],
"node": "node-1",
"total_processed": 2,
"total_successful": 2,
"correlation_id": "uuid-here"
}Example:
curl -X POST http://localhost:9080/api/cache/batch/set \
-H "Content-Type: application/json" \
-d '{
"items": [
{"key": "key1", "value": "value1", "ttl_hours": 2.0},
{"key": "key2", "value": "value2", "ttl_hours": 1.0}
]
}'All endpoints return consistent error responses:
400- Bad Request (invalid JSON, missing fields)404- Not Found (key doesn't exist)500- Internal Server Error (system failure)503- Service Unavailable (node unhealthy)
{
"error": "Detailed error message",
"code": "ERROR_CODE",
"correlation_id": "uuid-here",
"timestamp": "2025-08-21T17:53:16.266861Z"
}Content-Type: application/json
Accept: application/json
User-Agent: your-application/1.0Content-Type: application/json
X-Correlation-ID: uuid-here
X-Node-ID: node-1
X-Response-Time: 12ms# Set a value
curl -X PUT http://localhost:9080/api/cache/user:123 \
-H "Content-Type: application/json" \
-d '{"value": "{\"name\":\"John\",\"age\":30}", "ttl_hours": 24}'
# Get the value
curl -X GET http://localhost:9080/api/cache/user:123
# Delete the value
curl -X DELETE http://localhost:9080/api/cache/user:123# Store session data
curl -X PUT http://localhost:9080/api/cache/session:abc123 \
-H "Content-Type: application/json" \
-d '{"value": "{\"user_id\":123,\"expires\":1693234567}", "ttl_hours": 8}'# Batch load cache
curl -X POST http://localhost:9080/api/cache/batch/set \
-H "Content-Type: application/json" \
-d '{
"items": [
{"key": "config:app", "value": "{\"theme\":\"dark\"}", "ttl_hours": 168},
{"key": "config:db", "value": "{\"pool_size\":10}", "ttl_hours": 168}
]
}'# Check cluster health
for port in 9080 9081 9082; do
echo "Node $port:"
curl -X GET http://localhost:$port/health
echo ""
done- Throughput: ~10,000 requests/sec per node (hardware dependent)
- Batch Size: Maximum 100 items per batch operation
- Key Size: Maximum 250 characters
- Value Size: Maximum 1MB per value
- TTL Range: 1 second to 365 days
import requests
import json
# HyperCache client
class HyperCache:
def __init__(self, base_url="http://localhost:9080"):
self.base_url = base_url
def get(self, key):
response = requests.get(f"{self.base_url}/api/cache/{key}")
return response.json() if response.status_code == 200 else None
def set(self, key, value, ttl_hours=1.0):
data = {"value": value, "ttl_hours": ttl_hours}
response = requests.put(f"{self.base_url}/api/cache/{key}", json=data)
return response.status_code == 200
def delete(self, key):
response = requests.delete(f"{self.base_url}/api/cache/{key}")
return response.status_code == 200
# Usage
cache = HyperCache()
cache.set("user:123", '{"name":"John","age":30}', ttl_hours=2.0)
user = cache.get("user:123")const axios = require('axios');
class HyperCache {
constructor(baseUrl = 'http://localhost:9080') {
this.baseUrl = baseUrl;
}
async get(key) {
try {
const response = await axios.get(`${this.baseUrl}/api/cache/${key}`);
return response.data;
} catch (error) {
return null;
}
}
async set(key, value, ttlHours = 1.0) {
try {
const response = await axios.put(`${this.baseUrl}/api/cache/${key}`, {
value,
ttl_hours: ttlHours
});
return response.status === 200;
} catch (error) {
return false;
}
}
async delete(key) {
try {
const response = await axios.delete(`${this.baseUrl}/api/cache/${key}`);
return response.status === 200;
} catch (error) {
return false;
}
}
}
// Usage
const cache = new HyperCache();
await cache.set('user:123', JSON.stringify({name: 'John', age: 30}), 2.0);
const user = await cache.get('user:123');