file

package
v4.0.52 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

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

State is a simple file backed state store

func New

func New(fn string) (*State, error)

New will create a new state store backed by a file

func (*State) Close

func (f *State) Close() error

Close the state and sync data to the state file

func (*State) Delete

func (f *State) Delete(key string) error

Delete will return data for key in state

func (*State) Exists

func (f *State) Exists(key string) bool

Exists return true if the key exists in state

func (*State) Flush

func (f *State) Flush() error

Flush any pending data to storage

func (*State) Get

func (f *State) Get(key string, out interface{}) (bool, error)

Get will return a value for a given key or nil if not found

func (*State) Set

func (f *State) Set(key string, value interface{}) error

Set a value by key in state. the value must be able to serialize to JSON

func (*State) SetWithExpires

func (f *State) SetWithExpires(key string, value interface{}, expiry time.Duration) error

SetWithExpires will set key and value and it will automatically expire from state after expiry

Jump to

Keyboard shortcuts

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