store

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

func NewDB

func NewDB(tableName string, conn *sql.DB) *DB

func (*DB) All

func (d *DB) All(ctx context.Context) (map[string]*word.Word, error)

func (*DB) Get

func (d *DB) Get(ctx context.Context, nouns []string) (*GetResult, error)

func (*DB) Save

func (d *DB) Save(ctx context.Context, nouns map[string]*word.Word) error

type GetResult

type GetResult struct {
	Found    map[string]*word.Word
	NotFound []string
}

type Memory

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

func NewMemory

func NewMemory() *Memory

func (*Memory) All

func (m *Memory) All(_ context.Context) (map[string]*word.Word, error)

func (*Memory) Get

func (m *Memory) Get(_ context.Context, nouns []string) (*GetResult, error)

func (*Memory) Save

func (m *Memory) Save(_ context.Context, words map[string]*word.Word) error

type Proxy

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

func NewProxy

func NewProxy(hot Store, cold Store) *Proxy

func NewProxyMemoryAndDB

func NewProxyMemoryAndDB(tableName string, db *sql.DB) *Proxy

func (*Proxy) All

func (p *Proxy) All(ctx context.Context) (map[string]*word.Word, error)

func (*Proxy) Get

func (p *Proxy) Get(ctx context.Context, nouns []string) (*GetResult, error)

func (*Proxy) Save

func (p *Proxy) Save(ctx context.Context, words map[string]*word.Word) error

func (*Proxy) WarmUp

func (p *Proxy) WarmUp(ctx context.Context) (int, error)

func (*Proxy) WarmUpPeriodically

func (p *Proxy) WarmUpPeriodically(ctx context.Context, interval time.Duration)

type Store

type Store interface {
	All(ctx context.Context) (map[string]*word.Word, error)
	Get(ctx context.Context, nouns []string) (*GetResult, error)
	Save(ctx context.Context, words map[string]*word.Word) error
}

Jump to

Keyboard shortcuts

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