feat: Add basic key-value store example

- Added a client and server for a simple key-value store.
- Improved documentation with client and server usage examples.
- Created client and server implementations using the V language.
This commit is contained in:
Mahmoud Emad
2025-03-06 13:32:57 +02:00
parent ae7e7ecb84
commit d2c1be5396
5 changed files with 153 additions and 5 deletions

23
examples/data/ourdb_client.vsh Executable file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
// Please note that before running this script you need to run the server first
// See examples/data/ourdb_server.vsh
import freeflowuniverse.herolib.data.ourdb
import os
mut client := ourdb.new_client(
port: 3000
host: 'localhost'
)!
set := client.set('hello')!
get := client.get(set.id)!
assert set.id == get.id
println('Set result: ${set}')
println('Get result: ${get}')
// test delete functionality
client.delete(set.id)!

View File

@@ -4,7 +4,7 @@ import freeflowuniverse.herolib.data.ourdb
import os
mut server := ourdb.new_server(
port: 9000
port: 3000
allowed_hosts: ['localhost']
allowed_operations: ['set', 'get', 'delete']
secret_key: 'secret'