cacher

package
v3.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2017 License: MIT Imports: 3 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cacher

type Cacher interface {
	Get(string, time.Time, func() ([]byte, error)) func() ([]byte, error)
	Expire(string) error
}

Cacher defines the interface for a caching system so it can be customised.

func NewCacher

func NewCacher(engine common.Engine, maxQueueSize int, maxWorkers int) Cacher

NewCacher creates a new generic cacher with the given engine.

type CacherMock added in v1.0.1

type CacherMock struct {
	// ExpireFunc mocks the Expire function.
	ExpireFunc func(in1 string) error
	// GetFunc mocks the Get function.
	GetFunc func(in1 string, in2 time.Time, in3 func() ([]byte, error)) func() ([]byte, error)
}

CacherMock is a mock implementation of Cacher.

    func TestSomethingThatUsesCacher(t *testing.T) {

        // make and configure a mocked Cacher
        mockedCacher := &CacherMock{
            ExpireFunc: func(in1 string) error {
	               panic("TODO: mock out the Expire function")
            },
            GetFunc: func(in1 string, in2 time.Time, in3 func() ([]byte, error)) func() ([]byte, error) {
	               panic("TODO: mock out the Get function")
            },
        }

        // TODO: use mockedCacher in code that requires Cacher

    }

func (*CacherMock) Expire added in v1.0.1

func (mock *CacherMock) Expire(in1 string) error

Expire calls ExpireFunc.

func (*CacherMock) Get added in v1.0.1

func (mock *CacherMock) Get(in1 string, in2 time.Time, in3 func() ([]byte, error)) func() ([]byte, error)

Get calls GetFunc.

Jump to

Keyboard shortcuts

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