OCache provides an HTTP REST interface for cache operations.
The HTTP API runs on port 9001 by default (configurable with -http-port).
POST /v1/cache/{key}
Stores a cache item with the specified key.
Request Body Options:
- JSON format with base64-encoded data:
{
"key": "mykey",
"ttl_seconds": 3600,
"data": "aGVsbG8gd29ybGQ="
}- Raw binary data:
curl -X POST "http://localhost:9001/v1/cache/mykey" \
--data-binary @myfile.binResponse:
200 OKon success400 Bad Requestfor invalid input500 Internal Server Errorfor server errors
GET /v1/cache/{key}
Retrieves a cache item by key.
Example:
curl "http://localhost:9001/v1/cache/mykey"Response:
200 OKwith item data404 Not Foundif key doesn't exist500 Internal Server Errorfor server errors
DELETE /v1/cache/{key}
Removes a cache item by key.
Example:
curl -X DELETE "http://localhost:9001/v1/cache/mykey"Response:
200 OKon success (even if key didn't exist)500 Internal Server Errorfor server errors
GET /v1/cache
Lists all cache keys.
Example:
curl "http://localhost:9001/v1/cache"Response:
{
"keys": ["key1", "key2", "key3"]
}The HTTP API uses standard status codes:
200: Success400: Bad request (invalid input)404: Not found (key doesn't exist)500: Internal server error
- Small objects (< 64KB by default) are stored in RocksDB for fast access
- Large objects are stored on disk with metadata in RocksDB
- TTL is enforced through background cleanup processes
- The service is optimized for high throughput and low latency
# Store text data
curl -X POST "http://localhost:9001/v1/cache/greeting" \
-H "Content-Type: text/plain" \
--data "Hello, World!"
# Retrieve the data
curl "http://localhost:9001/v1/cache/greeting"# Store an image
curl -X POST "http://localhost:9001/v1/cache/logo" \
--data-binary @logo.png
# Store a PDF document
curl -X POST "http://localhost:9001/v1/cache/report" \
--data-binary @report.pdf# Store with 1 hour TTL
curl -X POST "http://localhost:9001/v1/cache/session" \
-H "Content-Type: application/json" \
--data '{
"key": "session",
"ttl_seconds": 3600,
"data": "eyJ1c2VyX2lkIjogMTIzLCAicm9sZSI6ICJhZG1pbiJ9"
}'- Client Documentation - Go client library and CLI client
- Configuration - Server configuration options
- Installation - Installation and setup guide