cache

package
v0.0.0-...-9451de5 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: BSD-3-Clause Imports: 2 Imported by: 0

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(entry CacheEntry) error
	List(keys ...string) ([]CacheEntry, error)
	FindByName(key string) (CacheEntry, error)
}

type CacheEntry

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

type CacheStorage

type CacheStorage interface {
	GetAll(keys ...string) ([]CacheEntry, error)
	Get(key string) (CacheEntry, error)
	Put(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 (m *MockAppCacheService) Create(e CacheEntry) error

func (*MockAppCacheService) FindByName

func (m *MockAppCacheService) FindByName(k string) (CacheEntry, error)

func (*MockAppCacheService) List

func (m *MockAppCacheService) List(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(key string) (CacheEntry, error)

func (*MockCacheStorage) GetAll

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

func (*MockCacheStorage) Put

func (m *MockCacheStorage) Put(e CacheEntry) error

Jump to

Keyboard shortcuts

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