database

package
v0.5.11 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Permission os.FileMode = 0666

Permission Permission of local database

Functions

func ChangeClientNumber

func ChangeClientNumber(in int)

ChangeClientNumber change client number

func GetClient

func GetClient() *client.Client

GetClient get database client

Types

type CacheNode

type CacheNode struct {
	Key, Value interface{}
}

CacheNode cache node

type LDB

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

LDB Local DB

func NewLDB

func NewLDB(name string, cacheCap int) *LDB

NewLDB new local db

func (*LDB) Close

func (d *LDB) Close()

Close close ldb

func (*LDB) LGet

func (d *LDB) LGet(chain uint64, tbName string, key []byte) []byte

LGet Local DB Get

func (*LDB) LGetNext

func (d *LDB) LGetNext(chain uint64, tbName string, prefix []byte) (k, v []byte)

LGetNext Local DB Get next,for visit all keys

func (*LDB) LSet

func (d *LDB) LSet(chain uint64, tbName string, key, value []byte) error

LSet Local DB Set,if value = nil,will delete the key

func (*LDB) SetCache

func (d *LDB) SetCache(tbName string)

SetCache set memory cache of the table

func (*LDB) SetNotDisk

func (d *LDB) SetNotDisk(tbName string, cap int)

SetNotDisk the data only in memory

type LRUCache

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

LRUCache lru cache

func NewLRUCache

func NewLRUCache(cap int) *LRUCache

NewLRUCache new cache

func (*LRUCache) Get

func (lru *LRUCache) Get(k interface{}) (v interface{}, ok bool)

Get get cache value

func (*LRUCache) GetNext

func (lru *LRUCache) GetNext(preKey interface{}) (k, v interface{}, ok bool)

GetNext get next item

func (*LRUCache) Set

func (lru *LRUCache) Set(k, v interface{})

Set add new item

func (*LRUCache) Size

func (lru *LRUCache) Size() int

Size get length of cached

Jump to

Keyboard shortcuts

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