cache

package
v1.1.1441 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cacheable

func Cacheable[K ristretto.Key, V any](key K, fn func() (V, error), c Backend[K, any]) (V, error)

Cacheable makes a function cacheable by the given key

func NewRistrettoCacheBackend

func NewRistrettoCacheBackend[K ristretto.Key, V any]() (*ristrettoCacheBackend[K, V], error)

NewRistrettoCacheBackend construct an instance of a ristrettoCacheBackend

Types

type Backend

type Backend[K ristretto.Key, V any] interface {
	Get(key K) (V, bool)
	Set(key K, value V) bool
}

Backend defines interface for a Backend

type MockBackend

type MockBackend[K z.Key, V interface{}] struct {
	mock.Mock
}

MockBackend is an autogenerated mock type for the Backend type

func NewMockBackend

func NewMockBackend[K z.Key, V interface{}](t interface {
	mock.TestingT
	Cleanup(func())
}) *MockBackend[K, V]

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[K, V]) EXPECT

func (_m *MockBackend[K, V]) EXPECT() *MockBackend_Expecter[K, V]

func (*MockBackend[K, V]) Get

func (_m *MockBackend[K, V]) Get(key K) (V, bool)

Get provides a mock function with given fields: key

func (*MockBackend[K, V]) Set

func (_m *MockBackend[K, V]) Set(key K, value V) bool

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

type MockBackend_Expecter

type MockBackend_Expecter[K z.Key, V interface{}] struct {
	// contains filtered or unexported fields
}

func (*MockBackend_Expecter[K, V]) Get

func (_e *MockBackend_Expecter[K, V]) Get(key interface{}) *MockBackend_Get_Call[K, V]

Get is a helper method to define mock.On call

  • key K

func (*MockBackend_Expecter[K, V]) Set

func (_e *MockBackend_Expecter[K, V]) Set(key interface{}, value interface{}) *MockBackend_Set_Call[K, V]

Set is a helper method to define mock.On call

  • key K
  • value V

type MockBackend_Get_Call

type MockBackend_Get_Call[K z.Key, V interface{}] 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[K, V]) Return

func (_c *MockBackend_Get_Call[K, V]) Return(_a0 V, _a1 bool) *MockBackend_Get_Call[K, V]

func (*MockBackend_Get_Call[K, V]) Run

func (_c *MockBackend_Get_Call[K, V]) Run(run func(key K)) *MockBackend_Get_Call[K, V]

func (*MockBackend_Get_Call[K, V]) RunAndReturn

func (_c *MockBackend_Get_Call[K, V]) RunAndReturn(run func(K) (V, bool)) *MockBackend_Get_Call[K, V]

type MockBackend_Set_Call

type MockBackend_Set_Call[K z.Key, V interface{}] 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[K, V]) Return

func (_c *MockBackend_Set_Call[K, V]) Return(_a0 bool) *MockBackend_Set_Call[K, V]

func (*MockBackend_Set_Call[K, V]) Run

func (_c *MockBackend_Set_Call[K, V]) Run(run func(key K, value V)) *MockBackend_Set_Call[K, V]

func (*MockBackend_Set_Call[K, V]) RunAndReturn

func (_c *MockBackend_Set_Call[K, V]) RunAndReturn(run func(K, V) bool) *MockBackend_Set_Call[K, V]

Jump to

Keyboard shortcuts

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