Fast and Cold - A minimalist in-memory database via Unix sockets
BeerCache is a simple and fast key-value database that runs in memory and communicates via Unix sockets. Perfect for local caching, sessions, or anything that needs to be as fast.
- In-memory: Everything stays in RAM, zero disk latency
- Unix Sockets: Ultra-fast local communication
- Thread-safe: Uses DashMap for concurrent access
- Binary protocol: Efficient and compact
- CRUD operations: Complete Create, Read, Update, Delete
# Default socket: /tmp/beer_cache.sock
cargo run
# Custom socket
SOCKET_NAME=my_cache cargo run| Operation | Code | Description |
|---|---|---|
| GET | 1 | Fetch a resource |
| GET_ALL | 2 | List all resources |
| SET | 3 | Create/update a resource |
| UPDATE | 4 | Update existing resource |
| DELETE | 5 | Remove a resource |
| DELETE_ALL | 6 | Clear everything |
| Code | Status | Description |
|---|---|---|
| 1 | OK | Success |
| 2 | CREATED | Resource created |
| 3 | NOT_FOUND | Resource not found |
| 4 | BAD_REQUEST | Invalid request |
BeerCache uses a simple binary protocol over Unix sockets.
[4 bytes: content_length][content]
[1 byte: operation][16 bytes: resource_id (optional)][body (optional)]
[4 bytes: content_length][1 byte: status_code][payload (optional)]
Request: [length][1][resource_id]
Response: [length][1][resource_body]
Request: [length][3][resource_id][resource_body]
Response: [length][2] (if created) or [length][1] (if updated)
Request: [length][2]
Response: [length][1][id1][body1_length][body1][id2][body2_length][body2]...
- Fixed 16-byte array
- Can be any binary data (UUIDs work great)
cargo build --releasetokio: Async runtimedashmap: Concurrent HashMap
Do whatever you want with it. It's just a cache.
