storagex

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventObserver

type EventObserver[T any] interface {
	BeforeLoad()
	AfterLoad(memD T, err error)
	BeforeSave()
	AfterSave(memD T, err error)
}

type FileStorage

type FileStorage interface {
	WriteFile(name string, d []byte) error
	ReadFile(name string) ([]byte, error)
}

func NewRawFSStorage

func NewRawFSStorage(rootPath string) FileStorage

type JSONSerial

type JSONSerial struct {
	MarshalIndent bool
}

func (*JSONSerial) Marshal

func (serial *JSONSerial) Marshal(t any) ([]byte, error)

func (*JSONSerial) Unmarshal

func (*JSONSerial) Unmarshal(d []byte, t any) error

type Lock

type Lock syncx.RWLocker

type MemWithFile

type MemWithFile[T any, S Serial, L syncx.RWLocker] struct {
	// contains filtered or unexported fields
}

func NewMemWithFile

func NewMemWithFile[T any, S Serial, L syncx.RWLocker](d T, serial S, lock L, fileName string, storage FileStorage) (
	*MemWithFile[T, S, L], error)

func NewMemWithFileEx

func NewMemWithFileEx[T any, S Serial, L syncx.RWLocker](d T, serial S, lock L, fileName string, storage FileStorage,
	ob EventObserver[T]) (*MemWithFile[T, S, L], error)

func NewMemWithFileEx1

func NewMemWithFileEx1[T any, S Serial, L syncx.RWLocker](d T, serial S, lock L, fileName string, storage FileStorage,
	ob EventObserver[T], autoSaveInterval time.Duration) (*MemWithFile[T, S, L], error)

func (*MemWithFile[T, S, L]) Change

func (mwf *MemWithFile[T, S, L]) Change(proc func(memD T) (newMemD T, err error)) error

func (*MemWithFile[T, S, L]) Read

func (mwf *MemWithFile[T, S, L]) Read(proc func(memD T))

type NoLock

type NoLock struct {
}

func (NoLock) Lock

func (NoLock) Lock()

func (NoLock) RLock

func (NoLock) RLock()

func (NoLock) RUnlock

func (NoLock) RUnlock()

func (NoLock) Unlock

func (NoLock) Unlock()

type Serial

type Serial interface {
	Marshal(t any) ([]byte, error)
	Unmarshal(d []byte, t any) error
}

type Storage

type Storage interface {
	Set(key string, v interface{}) error
	Get(key string, v interface{}) (ok bool, err error)
	Del(key string) error
}

type Storage2

type Storage2 interface {
	Storage

	SetAll(keys []string, vs ...interface{}) error
	GetAll(keys []string, vsi ...interface{}) (vs []interface{}, err error)
	DelAll(keys []string) error
}

type StorageCollect

type StorageCollect interface {
	GetList(itemGen func(key string) interface{}) (items []interface{}, err error)
	GetMap(itemGen func(key string) interface{}) (items map[string]interface{}, err error)
}

type StorageTiny

type StorageTiny interface {
	Storage
	StorageCollect
}

type StorageTiny2

type StorageTiny2 interface {
	Storage2
	StorageCollect
}

func NewKV

func NewKV(file string) (StorageTiny2, error)

func NewKVEx

func NewKVEx(file string, storage FileStorage) (StorageTiny2, error)

Jump to

Keyboard shortcuts

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