db

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBApi

type DBApi interface {
	NewLeaseID(ttl int64) (int64, error)
	KeepLease(leaseID int64) error
	PutWithLease(key string, value string, leaseID int64) error
	Put(key string, value string) error
	PutWithTTL(key string, value string, ttl int) error
	Get(key string) (string, error)
	GetWithChild(key string) ([]KeyValue, error)
	Del(key string) error
	Watch(key string) <-chan WatchEvent
}
var DB DBApi

func DbInit

func DbInit() DBApi

type DBClient

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

func (*DBClient) Del

func (this *DBClient) Del(key string) error

func (*DBClient) Get

func (this *DBClient) Get(key string) (string, error)

func (*DBClient) GetWithChild

func (this *DBClient) GetWithChild(key string) ([]KeyValue, error)

func (*DBClient) KeepLease

func (this *DBClient) KeepLease(leaseID int64) error

func (*DBClient) NewLeaseID

func (this *DBClient) NewLeaseID(ttl int64) (int64, error)

func (*DBClient) Put

func (this *DBClient) Put(key string, value string) error

func (*DBClient) PutWithLease

func (this *DBClient) PutWithLease(key string, value string, leaseID int64) error

func (*DBClient) PutWithTTL

func (this *DBClient) PutWithTTL(key string, value string, ttl int) error

func (*DBClient) Watch

func (this *DBClient) Watch(key string) <-chan WatchEvent

type EVENT_TYPE

type EVENT_TYPE int
const (
	EVENT_ADD EVENT_TYPE
	EVENT_UPDATE
	EVENT_DELETE
	EVENT_EXPIRE
)

type KeyValue

type KeyValue struct {
	Key   string
	Value string
}

type WatchEvent

type WatchEvent struct {
	Event EVENT_TYPE
	KeyValue
}

Jump to

Keyboard shortcuts

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