basiccacher

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2017 License: MIT Imports: 4 Imported by: 0

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) ([]byte, error)
	Put(string, time.Time, []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

type CacherMock struct {
	// ExpireFunc mocks the Expire method.
	ExpireFunc func(in1 string) error

	// GetFunc mocks the Get method.
	GetFunc func(in1 string) ([]byte, error)

	// PutFunc mocks the Put method.
	PutFunc func(in1 string, in2 time.Time, in3 []byte) error
	// contains filtered or unexported fields
}

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 method")
            },
            GetFunc: func(in1 string) ([]byte, error) {
	               panic("TODO: mock out the Get method")
            },
            PutFunc: func(in1 string, in2 time.Time, in3 []byte) error {
	               panic("TODO: mock out the Put method")
            },
        }

        // TODO: use mockedCacher in code that requires Cacher
        //       and then make assertions.

    }

func (*CacherMock) Expire

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

Expire calls ExpireFunc.

func (*CacherMock) ExpireCalls

func (mock *CacherMock) ExpireCalls() []struct {
	In1 string
}

ExpireCalls gets all the calls that were made to Expire. Check the length with:

len(mockedCacher.ExpireCalls())

func (*CacherMock) Get

func (mock *CacherMock) Get(in1 string) ([]byte, error)

Get calls GetFunc.

func (*CacherMock) GetCalls

func (mock *CacherMock) GetCalls() []struct {
	In1 string
}

GetCalls gets all the calls that were made to Get. Check the length with:

len(mockedCacher.GetCalls())

func (*CacherMock) Put

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

Put calls PutFunc.

func (*CacherMock) PutCalls

func (mock *CacherMock) PutCalls() []struct {
	In1 string
	In2 time.Time
	In3 []byte
}

PutCalls gets all the calls that were made to Put. Check the length with:

len(mockedCacher.PutCalls())

Jump to

Keyboard shortcuts

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