A lightweight, high-performance, in-memory key-value store service with a clean HTTP API interface.
- Go 1.23 or higher
# Clone the repository
git clone https://github.com/2k4sm/remoteDictionary.git
cd remoteDictionary
# Build the binary
go build -o remoteDictionary
# Run the server
./remoteDictionarygo install github.com/2k4sm/remoteDictionary@latest
# Run the server
./remoteDictionary# Build using
docker build -t remotedictionary .# Run using
docker run -p 7171:7171 remotedictionary# Pull the image using
docker pull sm2k4/remotedictionary:latest
# Run it using
docker run -p 7171:7171 sm2k4/remotedictionary:latestGiven below are the default values but you can change it by creating a .env file in the project root:
PORT=7171
MAX_KEY_SIZE=256
MAX_VALUE_SIZE=256
To enable the GitHub Actions pipeline, configure the following Repository Secrets:
| Secret Name | Description |
|---|---|
GCP_PROJECT_ID |
Your Google Cloud Project ID. |
GCP_WORKLOAD_IDENTITY_PROVIDER |
The full identifier of the Workload Identity Provider. |
GCP_SERVICE_ACCOUNT |
The email address of the Google Service Account. |
GKE_CLUSTER_NAME |
The name of your GKE cluster. |
GKE_ZONE |
The compute zone of your cluster (e.g., us-central1-a). |
DOCKER_USERNAME |
Your Docker Hub username. |
DOCKER_PASSWORD |
Your Docker Hub access token or password. |
POST /put
Request body:
{
"key": "user:1234",
"value": "John Doe"
}Response:
{
"status": "OK",
"message": "Key inserted/updated successfully."
}GET /get?key=user:1234
Success Response:
{
"status": "OK",
"key": "user:1234",
"value": "John Doe",
"message": "Key retrieved successfully."
}Key Not Found Response:
{
"status": "ERROR",
"message": "Key not found."
}The project utilizes a robust CI/CD pipeline powered by GitHub Actions.
Run on every push to main and Pull Requests:
- Linting: Uses
golangci-lintto ensure code quality. - Security Scanning:
- SAST:
gosecscans for security vulnerabilities in code. - SCA:
trivyscans dependencies for known vulnerabilities.
- SAST:
- Unit Tests: Runs
go test -raceto verification logic and concurrency. - Build: Verifies the application compiles successfully.
Triggered on successful runs on the main branch:
- Container Build: Builds the Docker image.
- Container Scan: Scans the image with
trivyfor OS-level vulnerabilities. - Deployment: Pushes the image to Docker Hub and deploys to the configured GKE cluster.
- Dynamic Scan: Runs OWASP ZAP (DAST) against the live deployment to check for runtime security issues.
-
LRU Cleanup: We remove the oldest, least-used items first when memory gets tight. This keeps only the stuff you're actually using.
-
Usage Monitor: The system keeps an eye on memory usage and automatically cleans up when it reaches 70% full, so it never crashes from running out of memory.
-
Gradual Cleanup: When clearing memory, we start by removing just a few items at a time, then gradually remove more if needed. This keeps the system responsive while freeing up space.
-
Buffer Reuse: We reuse memory buffers instead of creating new ones each time, which makes everything run faster during heavy usage.
-
Concurrent Access: The system allows multiple users to read data at the same time, while making sure updates happen safely without conflicts.
-
Request Limits: We put caps on request sizes to prevent anyone from crashing the system by sending extremely large requests.
-
Horizontal Scaling: The core service can be easily replicated across multiple servers with a load balancer since it doesn't rely on shared state (except for the cache itself).
-
Workload Adaptation: The system constantly monitors resource usage and adjusts to handle changing workloads.
Built by 2k4sm