Skip to content

A simple zero-dependency in-memory key-value store for Golang

License

Notifications You must be signed in to change notification settings

tech-branch/tbkv

Repository files navigation

tests continuous semgrep

TBKV key-val store

You're looking at a simple zero-dependency in-memory key-value store for Golang.

All operations (Get/Set/Delete) are executed in a single, buffered loop, so the store provides some thread safety.

The package is continuously scanned by semgrep and various static code critics to maintain healthy security posture.

The main tbkv package has 100% test coverage and my aim is to maintain that. The examples are covered to the extent of checking if the scenario runs successfully.

Usage

import (
	"github.com/tech-branch/tbkv"
)

func main() {
    kvs := NewDefaultStore()

    kvs.Set("key", "value")

    val, err := kvs.Get("key")
    if err != nil {
        return err
    }

    // val == "value"

    kvs.Delete("key")

    val, err := kvs.Get("key")
    if err != nil {
        // err == tbkv.ErrNotFound
        return err
    }
}

See a more complete example in ./examples/main.go

About

A simple zero-dependency in-memory key-value store for Golang

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published