pebble_driver

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: ISC Imports: 2 Imported by: 0

README

Pebble driver for Kilovolt

Simple Pebble driver for Kilovolt.

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/v7"
	pebble_driver "github.com/strimertul/kv-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