Project Details
HyperDB Go Client
Author: Afaan Bilal
Introduction
HyperDB Go is a Go client package for the HyperDB server.
Installation
go get -u github.com/AfaanBilal/hyperdb-go
Example usage
import (
"fmt"
"github.com/AfaanBilal/hyperdb-go"
)
hyper := hyperdb.Create("http://localhost:8765", "", "")
// Ping the server
rb := hyper.Ping()
fmt.Println(rb) // true
// Get the version number
rs := hyper.Version()
fmt.Println(rs) // "[HyperDB v0.1.0 (https://afaan.dev)]"
// Set a value
rs = hyper.Set("test", "value")
fmt.Println(rs) // "value"
// Check if a key is present
rb = hyper.Has("test")
fmt.Println(rb) // true
// Get a value
rs = hyper.Get("test")
fmt.Println(rs) // "value"
// Get all stored data
rs = hyper.All()
fmt.Println(rs) // {test: "value"}
// Remove a key
rb = hyper.Delete("test")
fmt.Println(rb) // true
// Delete all stored data
rb = hyper.Clear()
fmt.Println(rb) // true
// Check if the store is empty
rb = hyper.Empty()
fmt.Println(rb) // true
// Persist the store to disk
rb = hyper.Save()
fmt.Println(rb) // true
// Reload the store from disk
rb = hyper.Reload()
fmt.Println(rb) // true
// Delete all store data from memory and disk
rb = hyper.Reset()
fmt.Println(rb) // true
Test
$ go test . -v
=== RUN TestHyperDB
true
[HyperDB v0.2.0 (https://afaan.dev)]
value
true
value
{"test":"value"}
true
true
true
true
true
true
--- PASS: TestHyperDB (0.01s)
PASS
ok github.com/AfaanBilal/hyperdb-go 0.201s
Contributing
All contributions are welcome. Please create an issue first for any feature request
or bug. Then fork the repository, create a branch and make any changes to fix the bug
or add the feature and create a pull request. That's it!
Thanks!
License
HyperDB Go is released under the MIT License.
Check out the full license here.
License
MIT License
Copyright (c) 2023 Afaan Bilal
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.