cache

package
v0.0.0-...-5e8e33e Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithCache

func WithCache[T any](ctx context.Context, cache Cache, key string, ttl time.Duration, exec func() (*T, error)) (*T, error)

func WithDeleteCache

func WithDeleteCache(ctx context.Context, cache Cache, key string) error

func WithRefreshCache

func WithRefreshCache[T any](ctx context.Context, cache Cache, key string, ttl time.Duration, value *T) (*T, error)

Types

type Cache

type Cache interface {
	Get(ctx context.Context, key string) (string, bool)
	Set(ctx context.Context, key string, value string, ttl time.Duration)
	Delete(ctx context.Context, key string)
	Close(ctx context.Context) error
}

func NewRedisCache

func NewRedisCache(ctx context.Context, config *config.Config) Cache

type MockCache

type MockCache struct {
	mock.Mock
}

MockCache is an autogenerated mock type for the Cache type

func NewMockCache

func NewMockCache(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockCache

NewMockCache creates a new instance of MockCache. 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 (*MockCache) Close

func (_m *MockCache) Close(ctx context.Context) error

Close provides a mock function with given fields: ctx

func (*MockCache) Delete

func (_m *MockCache) Delete(ctx context.Context, key string)

Delete provides a mock function with given fields: ctx, key

func (*MockCache) Get

func (_m *MockCache) Get(ctx context.Context, key string) (string, bool)

Get provides a mock function with given fields: ctx, key

func (*MockCache) Set

func (_m *MockCache) Set(ctx context.Context, key string, value string, ttl time.Duration)

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

Jump to

Keyboard shortcuts

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