islazy: github.com/evilsocket/islazy/data Index | Files

package data

import "github.com/evilsocket/islazy/data"

Package data contains basic threadsafe data structures with filesystem persistance and configurable flushing policies.

Index

Package Files

doc.go flush.go unsortedkv.go

type FlushPolicy Uses

type FlushPolicy int

FlushPolicy is the type of flush policy to use.

const (
    // FlushOnEdit saves the object to disk after every modification.
    FlushOnEdit FlushPolicy = iota
    // FlushExplicit saves the object to disk only if the Flush method of
    // the object is explicitly called.
    FlushExplicit
    // FlushNone never saves the object to disk.
    FlushNone
)

type UnsortedKV Uses

type UnsortedKV struct {
    sync.Mutex
    // contains filtered or unexported fields
}

UnsortedKV is a thread safe and unsorted key-value storage with optional persistency on disk.

func NewDiskUnsortedKV Uses

func NewDiskUnsortedKV(fileName string) (*UnsortedKV, error)

NewDiskUnsortedKV returns an UnsortedKV that flushed data on disk every time it gets updated.

func NewDiskUnsortedKVReader Uses

func NewDiskUnsortedKVReader(fileName string) (*UnsortedKV, error)

NewDiskUnsortedKVReader returns an UnsortedKV from disk as a reader but it doesn't flush any modifications on disk.

func NewMemUnsortedKV Uses

func NewMemUnsortedKV() (*UnsortedKV, error)

NewMemUnsortedKV returns an UnsortedKV that only lives in memory and never persists on disk.

func NewUnsortedKV Uses

func NewUnsortedKV(fileName string, flushPolicy FlushPolicy) (*UnsortedKV, error)

NewUnsortedKV creates a new UnsortedKV with the given flush policy. If fileName already exists, it will be deserialized and loaded.

func (*UnsortedKV) Clear Uses

func (u *UnsortedKV) Clear() error

Clear deletes every named object from the store.

func (*UnsortedKV) Del Uses

func (u *UnsortedKV) Del(name string) error

Del deletes a named object from the store.

func (*UnsortedKV) Each Uses

func (u *UnsortedKV) Each(cb func(k, v string) bool)

Each iterates each named object in the store by executing the callback cb on them, if the callback returns true the iteration is interrupted.

func (*UnsortedKV) Empty Uses

func (u *UnsortedKV) Empty() bool

Empty returns bool if the store is empty.

func (*UnsortedKV) Flush Uses

func (u *UnsortedKV) Flush() error

Flush flushes the store to disk if the flush policy is different than FlushNone

func (*UnsortedKV) Get Uses

func (u *UnsortedKV) Get(name string) (v string, found bool)

Get return the value of the named object if present, or returns found as false otherwise.

func (*UnsortedKV) GetOr Uses

func (u *UnsortedKV) GetOr(name, or string) string

GetOr will return the value of the named object if present, or a default value.

func (*UnsortedKV) Has Uses

func (u *UnsortedKV) Has(name string) bool

Has return true if name exists in the store.

func (*UnsortedKV) MarshalJSON Uses

func (u *UnsortedKV) MarshalJSON() ([]byte, error)

MarshalJSON is used to serialize the UnsortedKV data structure to JSON correctly.

func (*UnsortedKV) Set Uses

func (u *UnsortedKV) Set(name, value string) error

Set sets a value for a named object.

Package data imports 7 packages (graph) and is imported by 7 packages. Updated 2018-10-30. Refresh now. Tools for package owners.