syncmap

package module
v0.0.0-...-a2c97f7 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Op

type Op struct {
	Type OpType `json:"op"`
	K    string `json:"k"`
	V    Value  `json:"v"`
}

type OpType

type OpType string
const (
	Set OpType = "set"
	Del OpType = "del"
)

type Patch

type Patch struct {
	Achieved        map[string]Value `json:"achieved"`
	AchievedVersion int64            `json:"achieved_version"`
	Op              []Op             `json:"op"`
}

type SyncMap

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

func New

func New(op_list_max_size int) *SyncMap

func (*SyncMap) AutoRemove

func (sm *SyncMap) AutoRemove()

func (*SyncMap) Del

func (sm *SyncMap) Del(key string)

func (*SyncMap) Diff

func (sm *SyncMap) Diff(after_version int64) Patch

func (*SyncMap) ForceAchieve

func (sm *SyncMap) ForceAchieve()

func (*SyncMap) Get

func (sm *SyncMap) Get(key string) Value

func (*SyncMap) Patch

func (sm *SyncMap) Patch(patch Patch)

func (*SyncMap) Set

func (sm *SyncMap) Set(key, value string)

func (*SyncMap) SetWithOptions

func (sm *SyncMap) SetWithOptions(key, value string, priority int, autoremove int)

func (*SyncMap) SetWithPriority

func (sm *SyncMap) SetWithPriority(key, value string, priority int)

func (*SyncMap) Size

func (sm *SyncMap) Size() int

func (*SyncMap) Version

func (sm *SyncMap) Version() int64

type Value

type Value struct {
	V        string `json:"v"`
	T        int64  `json:"t"`
	Priority int64  `json:"priority"`   // default: 0, the bigger value means higher priority
	Deadline int64  `json:"autoremove"` // Unix timestamp, Value will be auto removed if time.Now().Unix() > Deadline
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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