cache

package
v1.1.1039 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cacheable

func Cacheable[K any, V any](key K, fn func() (V, error), c *SharCache) (V, error)

Cacheable makes a function cacheable by the given key

func NewRistrettoCacheBackend

func NewRistrettoCacheBackend() (*ristrettoCacheBackend, error)

NewRistrettoCacheBackend construct an instance of a ristrettoCacheBackend

Types

type Backend

type Backend interface {
	Get(key interface{}) (interface{}, bool)
	Set(key interface{}, value interface{}) bool
}

Backend defines interface for a Backend

type MockBackend added in v1.1.1032

type MockBackend struct {
	mock.Mock
}

MockBackend is an autogenerated mock type for the Backend type

func NewMockBackend added in v1.1.1032

func NewMockBackend(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockBackend

NewMockBackend creates a new instance of MockBackend. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockBackend) EXPECT added in v1.1.1032

func (_m *MockBackend) EXPECT() *MockBackend_Expecter

func (*MockBackend) Get added in v1.1.1032

func (_m *MockBackend) Get(key interface{}) (interface{}, bool)

Get provides a mock function with given fields: key

func (*MockBackend) Set added in v1.1.1032

func (_m *MockBackend) Set(key interface{}, value interface{}) bool

Set provides a mock function with given fields: key, value

type MockBackend_Expecter added in v1.1.1032

type MockBackend_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockBackend_Expecter) Get added in v1.1.1032

func (_e *MockBackend_Expecter) Get(key interface{}) *MockBackend_Get_Call

Get is a helper method to define mock.On call

  • key interface{}

func (*MockBackend_Expecter) Set added in v1.1.1032

func (_e *MockBackend_Expecter) Set(key interface{}, value interface{}) *MockBackend_Set_Call

Set is a helper method to define mock.On call

  • key interface{}
  • value interface{}

type MockBackend_Get_Call added in v1.1.1032

type MockBackend_Get_Call struct {
	*mock.Call
}

MockBackend_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'

func (*MockBackend_Get_Call) Return added in v1.1.1032

func (_c *MockBackend_Get_Call) Return(_a0 interface{}, _a1 bool) *MockBackend_Get_Call

func (*MockBackend_Get_Call) Run added in v1.1.1032

func (_c *MockBackend_Get_Call) Run(run func(key interface{})) *MockBackend_Get_Call

func (*MockBackend_Get_Call) RunAndReturn added in v1.1.1032

func (_c *MockBackend_Get_Call) RunAndReturn(run func(interface{}) (interface{}, bool)) *MockBackend_Get_Call

type MockBackend_Set_Call added in v1.1.1032

type MockBackend_Set_Call struct {
	*mock.Call
}

MockBackend_Set_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Set'

func (*MockBackend_Set_Call) Return added in v1.1.1032

func (*MockBackend_Set_Call) Run added in v1.1.1032

func (_c *MockBackend_Set_Call) Run(run func(key interface{}, value interface{})) *MockBackend_Set_Call

func (*MockBackend_Set_Call) RunAndReturn added in v1.1.1032

func (_c *MockBackend_Set_Call) RunAndReturn(run func(interface{}, interface{}) bool) *MockBackend_Set_Call

type MockCacheBackend

type MockCacheBackend struct {
	mock.Mock
}

MockCacheBackend is an autogenerated mock type for the Backend type

func NewMockCacheBackend

func NewMockCacheBackend(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockCacheBackend

NewMockCacheBackend creates a new instance of MockCacheBackend. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockCacheBackend) EXPECT

func (*MockCacheBackend) Get

func (_m *MockCacheBackend) Get(key interface{}) (interface{}, bool)

Get provides a mock function with given fields: key

func (*MockCacheBackend) Set

func (_m *MockCacheBackend) Set(key interface{}, value interface{}) bool

Set provides a mock function with given fields: key, value

type MockCacheBackend_Expecter

type MockCacheBackend_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockCacheBackend_Expecter) Get

func (_e *MockCacheBackend_Expecter) Get(key interface{}) *MockCacheBackend_Get_Call

Get is a helper method to define mock.On call

  • key interface{}

func (*MockCacheBackend_Expecter) Set

func (_e *MockCacheBackend_Expecter) Set(key interface{}, value interface{}) *MockCacheBackend_Set_Call

Set is a helper method to define mock.On call

  • key interface{}
  • value interface{}

type MockCacheBackend_Get_Call

type MockCacheBackend_Get_Call struct {
	*mock.Call
}

MockCacheBackend_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'

func (*MockCacheBackend_Get_Call) Return

func (_c *MockCacheBackend_Get_Call) Return(_a0 interface{}, _a1 bool) *MockCacheBackend_Get_Call

func (*MockCacheBackend_Get_Call) Run

func (_c *MockCacheBackend_Get_Call) Run(run func(key interface{})) *MockCacheBackend_Get_Call

func (*MockCacheBackend_Get_Call) RunAndReturn

func (_c *MockCacheBackend_Get_Call) RunAndReturn(run func(interface{}) (interface{}, bool)) *MockCacheBackend_Get_Call

type MockCacheBackend_Set_Call

type MockCacheBackend_Set_Call struct {
	*mock.Call
}

MockCacheBackend_Set_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Set'

func (*MockCacheBackend_Set_Call) Return

func (*MockCacheBackend_Set_Call) Run

func (_c *MockCacheBackend_Set_Call) Run(run func(key interface{}, value interface{})) *MockCacheBackend_Set_Call

func (*MockCacheBackend_Set_Call) RunAndReturn

func (_c *MockCacheBackend_Set_Call) RunAndReturn(run func(interface{}, interface{}) bool) *MockCacheBackend_Set_Call

type SharCache

type SharCache struct {
	// contains filtered or unexported fields
}

SharCache provides caching capabilities

func NewSharCache

func NewSharCache(backend Backend) *SharCache

NewSharCache constructs a new SharCache

Jump to

Keyboard shortcuts

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