db

package module
v0.0.0-...-46a7a98 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: BSD-3-Clause Imports: 7 Imported by: 3

README

go-db.v1

GoDoc

A simple key/value. We use https://github.com/prologic/bitcask at backend.

Installation

go get -u github.com/HuguesGuilleus/go-db.v1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB is a data base

func New

func New(name string, opt ...bitcask.Option) (db *DB)

Open a new DabatBase

func (*DB) Delete

func (db *DB) Delete(key Key)

Delete on element

func (*DB) DeleteAll

func (db *DB) DeleteAll()

Remove all keys in the DB.

func (*DB) DeleteS

func (db *DB) DeleteS(key string)

Delete on element

func (*DB) ForS

func (db *DB) ForS(prefix string, page, size int, filter func(string) bool, it interface{}) (total int)

Make an iteration on all the element in the DB that begins with prefix.

Page is the index of the page of length size. If zero, web take all keys.

We can select some elements with them key, so we use filter. filter can be nil.

It must be a function that take a string and a other type for the value, else it panic.

MyDB.For(func(k db.Key, v MyType){...})

total is the number of elements in the DB with prefix and that pass filter.

func (*DB) Get

func (db *DB) Get(key Key, v interface{}) (noExist bool)

Get the element with a number key and save it in v.

func (*DB) GetRaw

func (db *DB) GetRaw(key Key) []byte

Get the value in without decoding with a number key.

func (*DB) GetS

func (db *DB) GetS(key string, v interface{}) (noExist bool)

Get the element with a string key and save it in v.

func (*DB) GetSRaw

func (db *DB) GetSRaw(key string) []byte

Get the value in without decoding with a string key.

func (*DB) New

func (db *DB) New() Key

Create a new number index in the DB.

func (*DB) Set

func (db *DB) Set(key Key, v interface{})

Save with a number key, the value v in the DB with serialization.

func (*DB) SetRaw

func (db *DB) SetRaw(key Key, raw []byte)

Set with a number key, the value v without serialization.

func (*DB) SetS

func (db *DB) SetS(key string, v interface{})

Save with a string key, the value v in the DB with serialization.

func (*DB) SetSRaw

func (db *DB) SetSRaw(key string, raw []byte)

Set with a string key, the value v without serialization.

func (*DB) Unknown

func (db *DB) Unknown(key Key) bool

Return true if the key is unknown in the DB.

func (*DB) UnknownS

func (db *DB) UnknownS(key string) bool

type Key

type Key uint32

An number type key.

func KeyFromString

func KeyFromString(s string) Key

Convert a string who represent a decimal number to a key. If error the key value if zero.

func (Key) String

func (k Key) String() string

Get the key string in decimal format.

Jump to

Keyboard shortcuts

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