storage

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Persistor

type Persistor interface {
	Run(time.Duration)
	Read() <-chan string
	Write(data string)
	Flush() error
	Truncate() error
	File() *os.File
	Close() error
}

func NewAOFPersistor

func NewAOFPersistor(path ...string) (Persistor, error)

NewAOFPersistor creates a new append only file if no path is provided it will default to the current working directory

func NewMockAOFPersistor

func NewMockAOFPersistor(_ ...string) (Persistor, error)

NewMockAOFPersistor creates a new mock AOFPersistor implementation used for when AOF service is disabled

type Store

type Store interface {
	// Set inserts a key-value data
	Set(key string, value string)

	// SetEX inserts an expirable key-value data
	SetEX(key string, value string, expiresAfter int)

	// Get returns the value of the given key
	Get(key string) string

	// Remove deletes an item by the given key
	Remove(key string) int

	// Flush deletes all keys
	Flush()

	// Iter represents an iterator for the table
	Iter() <-chan *hashtable.Entry

	// Exist returns true if an item with the given key exists otherwise returns false
	Exist(key string) bool

	// Size returns the amount of entries in the table
	Size() int
}

Store is the representation of a key-value pair storage

func New

func New() Store

New creates a new storage for data structures

Jump to

Keyboard shortcuts

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