8000 GitHub - autom8ter/mappy: persistant, concurrency safe, chain-able hash tables
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 4, 2021. It is now read-only.

autom8ter/mappy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mappy

-- import "github.com/autom8ter/mappy"

Usage

var DefaultOpts = &Opts{
	Path:    "/tmp/mappy",
	Restore: true,
}
var Done = errors.New("mappy: done")

type BackupOpts

type BackupOpts struct {
	Dest io.Writer
}

type Bucket

type Bucket interface {
	Key() interface{}
	Path() []interface{}
	NewRecord(opts *RecordOpts) *Record
	Nest(key interface{}) Bucket
	NestedBuckets() []Bucket
	Del(opts *DelOpts) error
	Flush(opts *FlushOpts) error
	Count(opts *LenOpts) int
	Get(opts *GetOpts) (value *Record, ok bool)
	Set(opts *SetOpts) (*Record, error)
	View(opts *ViewOpts) error
	OnChange(fns ...ChangeHandlerFunc)
}

type BucketOpts

type BucketOpts struct {
	Path     []string
	GlobalId string
}

type ChangeHandlerFunc

type ChangeHandlerFunc func(bucket Bucket, log *Log) error

type CloseOpts

type CloseOpts struct {
}

type DelOpts

type DelOpts struct {
	Key interface{}
}

type DestroyOpts

type DestroyOpts struct {
}

type FlushOpts

type FlushOpts struct {
}

type GetOpts

type GetOpts struct {
	Key interface{}
}

type LenOpts

type LenOpts struct {
}

type Log

type Log struct {
	Sequence  int
	Op        Op
	Record    *Record
	CreatedAt time.Time
}

type Mappy

type Mappy interface {
	Bucket
	GetRecord(globalId string) (*Record, bool)
	GetBucket(path []interface{}) Bucket
	Close(opts *CloseOpts) error
	DestroyLogs(opts *DestroyOpts) error
	ReplayLogs(opts *ReplayOpts) error
	BackupLogs(opts *BackupOpts) (int64, error)
}

func Open

func Open(opts *Opts) (Mappy, error)

type Op

type Op int
const (
	DELETE Op = 2
	SET    Op = 3
)

type Opts

type Opts struct {
	Path    string
	Restore bool
}

type Record

type Record struct {
	Key        interface{}   `json:"key"`
	Val        interface{}   `json:"val"`
	BucketPath []interface{} `json:"bucketPath"`
	GloablId   string        `json:"globalId"`
	UpdatedAt  time.Time     `json:"updatedAt"`
}

func NewRecord

func NewRecord(opts *RecordOpts) *Record

type RecordOpts

type RecordOpts struct {
	Key interface{}
	Val interface{}
}

type ReplayFunc

type ReplayFunc func(bucket Bucket, lg *Log) error

type ReplayOpts

type ReplayOpts struct {
	Min int
	Max int
	Fn  ReplayFunc
}

type RestoreOpts

type RestoreOpts struct {
}

type SetOpts

type SetOpts struct {
	Record *Record
}

type ViewFunc

type ViewFunc func(bucket Bucket, record *Record) error

type ViewOpts

type ViewOpts struct {
	ViewFn ViewFunc
}

About

persistant, concurrency safe, chain-able hash tables

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

0