cache

package
v0.0.0-...-6f95374 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[T any] interface {
	Get(context.Context, string) (T, error)
	Set(context.Context, string, T, time.Duration) error
	Del(context.Context, string) error
	GetDel(context.Context, string) (T, error)
	CreateTxSetCmd(context.Context, string, T, time.Duration) (TxSetCmd, error)
	CreateTxDelCmd(context.Context, string) (TxDelCmd, error)
	Tx(context.Context, []TxSetCmd, []TxDelCmd) error
	Keys(context.Context, string, Prefix) ([]string, error)
}

type CacheMock

type CacheMock[V any] struct {
	T                    *testing.T
	Value                V
	GetAssert            func(t *testing.T, key string)
	GetErr               error
	SetAssert            func(t *testing.T, key string, value V, ttl time.Duration)
	SetErr               error
	DelAssert            func(t *testing.T, key string)
	DelErr               error
	GetDelAssert         func(t *testing.T, key string)
	GetDelErr            error
	CreateTxSetCmdAssert func(t *testing.T, key string, value V, ttl time.Duration)
	CreateTxSetCmdErr    error
	CreateTxDelCmdAssert func(t *testing.T, key string)
	CreateTxDelCmdErr    error
	TxAssert             func(t *testing.T, setCmds []TxSetCmd, delCmds []TxDelCmd)
	TxErr                error
	KeysValue            []string
	KeysAssert           func(t *testing.T, pattern string, prefix Prefix)
	KeysErr              error
}

func (*CacheMock[V]) CreateTxDelCmd

func (mock *CacheMock[V]) CreateTxDelCmd(ctx context.Context, key string) (TxDelCmd, error)

func (*CacheMock[V]) CreateTxSetCmd

func (mock *CacheMock[V]) CreateTxSetCmd(ctx context.Context, key string, value V, ttl time.Duration) (TxSetCmd, error)

func (*CacheMock[V]) Del

func (mock *CacheMock[V]) Del(ctx context.Context, key string) error

func (*CacheMock[V]) Get

func (mock *CacheMock[V]) Get(ctx context.Context, key string) (V, error)

func (*CacheMock[V]) GetDel

func (mock *CacheMock[V]) GetDel(ctx context.Context, key string) (V, error)

func (*CacheMock[V]) Keys

func (mock *CacheMock[V]) Keys(ctx context.Context, pattern string, prefix Prefix) ([]string, error)

func (*CacheMock[V]) Set

func (mock *CacheMock[V]) Set(ctx context.Context, key string, value V, ttl time.Duration) error

func (*CacheMock[V]) Tx

func (mock *CacheMock[V]) Tx(ctx context.Context, setCmds []TxSetCmd, delCmds []TxDelCmd) error

type Prefix

type Prefix bool
const (
	WithPrefix    Prefix = true
	WithoutPrefix Prefix = false
)

type TxDelCmd

type TxDelCmd struct {
	Key string
}

type TxSetCmd

type TxSetCmd struct {
	Key   string
	Value string
	TTL   time.Duration
}

Jump to

Keyboard shortcuts

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