store

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvSecret = "MEMO_SECRET"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheTarget added in v0.8.0

type CacheTarget struct {
	Target    string
	Cache     []string
	Len       int
	DocId     uint64
	UpdatedAt int64
}

CacheTarget : data structure handling search payload cache

type Codec

type Codec interface {
	// Marshal encodes a Memo to a slice of bytes.
	Marshal(v any) ([]byte, error)
	// Unmarshal decodes a slice of bytes into a Memo.
	Unmarshal(data []byte, v any) error
}

Codec encodes/decodes Memo to/from slices of bytes.

type DefaultCodec added in v0.6.0

type DefaultCodec struct{}

DefaultCodec encodes/decodes Memo to/from gob. You can use encoding.Gob instead of creating an instance of this struct.

func (DefaultCodec) Marshal added in v0.6.0

func (c DefaultCodec) Marshal(v any) ([]byte, error)

Marshal encodes a Go value to gob.

func (DefaultCodec) Unmarshal added in v0.6.0

func (c DefaultCodec) Unmarshal(data []byte, v any) error

Unmarshal decodes a gob value into a Go value.

type IndexedStore added in v0.8.0

type IndexedStore interface {
	Store

	CreateCacheTarget(docId uint64, m *Memo) error
	ForEachCacheTarget(fn func(k uint64, v *CacheTarget) error) error
	DeleteCacheTarget(docId uint64) error
}

type Memo

type Memo struct {
	Title     string `yaml:"title"`
	Content   string `yaml:"content,omitempty"`
	Encrypted bool   `yaml:"encrypted"`
	UpdatedAt int64  `yaml:"-"`
}

type Store

type Store interface {
	// Create creates a new Memo.
	Create(v *Memo) (uint64, error)

	Update(k uint64, v *Memo) error

	// Get retrieves the value for the given key.
	Get(k uint64, v *Memo) (bool, error)
	// Delete deletes the stored value for the given key.
	Delete(k uint64) (bool, error)
	// Count counts stored items
	Count() (int, error)
	// ForEach iterate over all keys.
	ForEach(fn func(k uint64, v *Memo) error) error
	// Close must be called when the work with the key-value store is done.
	Close() error
}

Store is an abstraction for different Memo store implementations.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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