cache

package
v0.0.0-...-15beef2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: BSD-3-Clause Imports: 3 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEntryNotFound = errors.New("cache entry not found")
)

Functions

This section is empty.

Types

type AppCacheService

type AppCacheService interface {
	Create(ctx context.Context, entry CacheEntry) error
	List(ctx context.Context, keys ...string) ([]CacheEntry, error)
	FindByName(ctx context.Context, key string) (CacheEntry, error)
}

type CacheEntry

type CacheEntry struct {
	Key      string
	Value    string
	ExpireAt time.Time
}

type CacheStorage

type CacheStorage interface {
	GetAll(ctx context.Context, keys ...string) ([]CacheEntry, error)
	Get(ctx context.Context, key string) (CacheEntry, error)
	Put(ctx context.Context, entry CacheEntry) error
}

type MockAppCacheService

type MockAppCacheService struct {
	OnCreate     func(CacheEntry) error
	OnList       func(...string) ([]CacheEntry, error)
	OnFindByName func(string) (CacheEntry, error)
}

MockAppCacheService implements AppCacheService interface

func (*MockAppCacheService) Create

func (*MockAppCacheService) FindByName

func (m *MockAppCacheService) FindByName(ctx context.Context, k string) (CacheEntry, error)

func (*MockAppCacheService) List

func (m *MockAppCacheService) List(ctx context.Context, keys ...string) ([]CacheEntry, error)

type MockCacheStorage

type MockCacheStorage struct {
	OnPut    func(CacheEntry) error
	OnGetAll func(...string) ([]CacheEntry, error)
	OnGet    func(string) (CacheEntry, error)
}

MockCacheStorage implements CacheStorage interface

func (*MockCacheStorage) Get

func (m *MockCacheStorage) Get(ctx context.Context, key string) (CacheEntry, error)

func (*MockCacheStorage) GetAll

func (m *MockCacheStorage) GetAll(ctx context.Context, keys ...string) ([]CacheEntry, error)

func (*MockCacheStorage) Put

Jump to

Keyboard shortcuts

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