pebble_driver

package module
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: ISC Imports: 3 Imported by: 0

README

Pebble driver for Kilovolt

Simple Pebble driver for Kilovolt.

Since Pebble has no fixed versioning data, please refer to the table below for tags to use:

kv-pebble version Pebble version tag Kilovolt version
<= v1.1.1 v0.0.0-20220127212634-b958d9a7760b v8.0.5
v1.2.0 v0.0.0-20221116223310-87eccabb90a3 v9.0.0
v1.2.1 v0.0.0-20230209222158-0568b5fd3d14 v9.0.1
v1.2.2 v0.0.0-20230418161327-101876aa7088 v10.0.0
v1.2.4 v0.0.0-20231102162011-844f0582c2eb v11.0.1

Usage

Usage is literally a function call to wrap an existing Pebble instance in a Kilovolt driver interface and then passing it over.

package example

import (
	"github.com/cockroachdb/pebble"
	kv "github.com/strimertul/kilovolt/v11"
	pebble_driver "git.sr.ht/~ashkeel/kilovolt-driver-pebble"
)

func main() {
	// Initialize your database
	db, err := pebble.Open("test", &pebble.Options{})
	if err != nil {
		panic(err)
	}
	defer db.Close()

	// Create driver using database instance, second parameter is "sync" (should be kept to true)
	driver := pebble_driver.NewPebbleBackend(db, true)

	// Pass it to Kilovolt
	hub, err := kv.NewHub(driver, kv.HubOptions{}, nil)
	if err != nil {
		panic(err)
	}
	go hub.Run()

	// etc.
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

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

func NewPebbleBackend

func NewPebbleBackend(db *pebble.DB, sync bool) Driver

func (Driver) Delete

func (b Driver) Delete(key string) error

func (Driver) Get

func (b Driver) Get(key string) (string, error)

func (Driver) GetBulk

func (b Driver) GetBulk(keys []string) (map[string]string, error)

func (Driver) GetPrefix

func (b Driver) GetPrefix(prefix string) (map[string]string, error)

func (Driver) List

func (b Driver) List(prefix string) ([]string, error)

func (Driver) Set

func (b Driver) Set(key, value string) error

func (Driver) SetBulk

func (b Driver) SetBulk(kv map[string]string) error

Jump to

Keyboard shortcuts

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