hyperdb

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2023 License: MIT Imports: 4 Imported by: 0

README

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.

Documentation

Index

Constants

View Source
const R_AUTH_FAILED string = "AUTH_FAILED"
View Source
const R_INVALID_CREDENTIALS string = "INVALID_CREDENTIALS"
View Source
const R_OK string = "OK"
View Source
const R_PONG string = "PONG"
View Source
const R_TRUE string = "YES"

Variables

This section is empty.

Functions

This section is empty.

Types

type HyperDB

type HyperDB struct {
	// contains filtered or unexported fields
}

func Create

func Create(address string, username string, password string) HyperDB

func (*HyperDB) All

func (h *HyperDB) All() string

func (*HyperDB) Clear

func (h *HyperDB) Clear() bool

func (*HyperDB) Delete

func (h *HyperDB) Delete(key string) bool

func (*HyperDB) Empty

func (h *HyperDB) Empty() bool

func (*HyperDB) Get

func (h *HyperDB) Get(key string) string

func (*HyperDB) Has

func (h *HyperDB) Has(key string) bool

func (*HyperDB) Ping

func (h *HyperDB) Ping() bool

func (*HyperDB) Reload

func (h *HyperDB) Reload() bool

func (*HyperDB) Reset

func (h *HyperDB) Reset() bool

func (*HyperDB) Save

func (h *HyperDB) Save() bool

func (*HyperDB) Set

func (h *HyperDB) Set(key string, value string) string

func (*HyperDB) Version

func (h *HyperDB) Version() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL