Ensure you have Java 21 installed:
java -version # Should show Java 21 or later
cd cube-db mvn clean package
Expected output:
[INFO] BUILD SUCCESS [INFO] Total time: 15.432 s
Option A - Using the startup script:
./start.sh
Option B - Direct Java command:
java -jar target/cube-db-1.0.0.jar
Option C - Using Maven:
mvn spring-boot:run
Wait for:
Started CubeApplication in 3.456 seconds
Open another terminal and run:
# Test health
curl http://localhost:8080/api/v1/health
# Store data
curl -X POST http://localhost:8080/api/v1/put \
-H "Content-Type: application/json" \
-d '{"key":"hello","value":"world"}'
# Retrieve data
curl http://localhost:8080/api/v1/get/hello
Or run the automated test script:
./test-api.sh
curl -X POST http://localhost:8080/api/v1/put \
-H "Content-Type: application/json" \
-d '{"key":"user:123","value":"Alice"}'
curl http://localhost:8080/api/v1/get/user:123
# Store multiple related keys
curl -X POST http://localhost:8080/api/v1/put \
-H "Content-Type: application/json" \
-d '{"key":"user:1:name","value":"Alice"}'
curl -X POST http://localhost:8080/api/v1/put \
-H "Content-Type: application/json" \
-d '{"key":"user:1:email","value":"alice@example.com"}'
# Scan all user:1 keys
curl "http://localhost:8080/api/v1/scan?prefix=user:1"
curl -X DELETE http://localhost:8080/api/v1/delete/user:123
curl http://localhost:8080/api/v1/stats
# Compile mvn compile # Run examples mvn exec:java -Dexec.mainClass="com.cube.examples.CubeExamples"
# All tests mvn test # Specific test mvn test -Dtest=CubeStorageEngineTest # With details mvn test -X
java -Dserver.port=9090 -jar target/cube-db-1.0.0.jar
java -Dcube.datadir=/path/to/data -jar target/cube-db-1.0.0.jar
java -Xmx2G -jar target/cube-db-1.0.0.jar
java -Xmx2G \
-Dserver.port=9090 \
-Dcube.datadir=/var/lib/cube \
-jar target/cube-db-1.0.0.jar
import com.cube.storage.LSMStorageEngine;
public class MyApp {
public static void main(String[] args) throws Exception {
// Create storage
LSMStorageEngine storage = new LSMStorageEngine("/tmp/mydata");
// Write
storage.put("key1", "value1".getBytes());
// Read
byte[] value = storage.get("key1");
System.out.println(new String(value));
// Close
storage.close();
}
}
# Find and kill process lsof -ti:8080 | xargs kill -9 # Or use different port java -Dserver.port=9090 -jar target/cube-db-1.0.0.jar
# Rebuild mvn clean package
# Use directory with write permission java -Dcube.datadir=$HOME/cube-data -jar target/cube-db-1.0.0.jar
# Clean and rebuild mvn clean test
mvn exec:java -Dexec.mainClass="com.cube.examples.CubeExamples"🎉 Congratulations! You're running Cube Database!