snapshot

package
v0.0.0-...-8c342a6 Latest Latest
Warning

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

Go to latest
Published: May 17, 2017 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetricsHook

type MetricsHook func(numUpdates int64, numElements int)

type Snapshot

type Snapshot struct {
	MetricsHook MetricsHook
	// contains filtered or unexported fields
}

func New

func New(n int) *Snapshot

New create a new snapshot with a barrier for n external goroutines plus internal go routines.

func (*Snapshot) Cancel

func (s *Snapshot) Cancel()

Cancel the Snapshot from Flushing/Checking of the Snapshot. Mostly for shutdown.

func (*Snapshot) Check

func (s *Snapshot) Check() error

Check is called by all clients

func (*Snapshot) Flush

func (s *Snapshot) Flush(flushDone func() error) error

Flush swaps the current Snapshot to stable. To avoid the user-goroutines changing the states at the same time, it synchronizes using a barrier. After swap, it flushes all stable entries. This function must never be executed concurrently, otherwise it will panic.

func (*Snapshot) Get

func (s *Snapshot) Get(key string, clone cloner) (interface{}, bool, error)

Get returns a value from the Snapshot identified by passed key. It will search in the current Snapshot and returns its value directly,git otherwise check in the last Snapshot (stable) and return a cloned value.

func (*Snapshot) Has

func (s *Snapshot) Has(key string) bool

func (*Snapshot) Keys

func (s *Snapshot) Keys() []string

func (*Snapshot) Set

func (s *Snapshot) Set(key string, value interface{}, encoded bool, flush flusher, evict evicter)

Set adds a new key/value pair to the Snapshot, defining how the value will be evicted and flushed, on appropriate times. if the value already exists, the evicter/flusher are being overwritten.

Jump to

Keyboard shortcuts

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