https://github.com/afaanbilal/hyperdb-go
HyperDB Go is a Go client package for the HyperDB server.
https://github.com/afaanbilal/hyperdb-go
go golang golang-package hyperdb
Last synced: 11 months ago
JSON representation
HyperDB Go is a Go client package for the HyperDB server.
- Host: GitHub
- URL: https://github.com/afaanbilal/hyperdb-go
- Owner: AfaanBilal
- License: mit
- Created: 2023-01-14T06:38:52.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-01-14T06:48:40.000Z (about 3 years ago)
- Last Synced: 2024-06-21T18:09:48.569Z (over 1 year ago)
- Topics: go, golang, golang-package, hyperdb
- Language: Go
- Homepage: https://pkg.go.dev/github.com/AfaanBilal/hyperdb-go
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
HyperDB Go Client
=================
Author: **[Afaan Bilal](https://afaan.dev)**
## Introduction
**HyperDB Go** is a Go client package for the [HyperDB server](https://github.com/AfaanBilal/hyperdb).
## Installation
````
go get -u github.com/AfaanBilal/hyperdb-go
````
## Example usage
````go
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).