cache

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: AGPL-3.0, AGPL-3.0-only Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCacheNotSameType = errors.New("cached item have is not same type as expected result")

Functions

This section is empty.

Types

type GenericCache

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

type Mem

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

Mem store data in memory, will be used to cache user group permission rule.

func NewMemoryCache

func NewMemoryCache() *Mem

func (*Mem) Get

func (c *Mem) Get(_ context.Context, key string, value interface{}) (bool, error)

func (*Mem) Set

func (c *Mem) Set(_ context.Context, key string, value interface{}, ttl time.Duration) error

type MockGenericCache

type MockGenericCache struct {
	mock.Mock
}

MockGenericCache is an autogenerated mock type for the GenericCache type

func (*MockGenericCache) EXPECT

func (*MockGenericCache) Get

func (_m *MockGenericCache) Get(ctx context.Context, key string, value interface{}) (bool, error)

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

func (*MockGenericCache) Set

func (_m *MockGenericCache) Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error

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

type MockGenericCache_Expecter

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

func (*MockGenericCache_Expecter) Get

func (_e *MockGenericCache_Expecter) Get(ctx interface{}, key interface{}, value interface{}) *MockGenericCache_Get_Call

Get is a helper method to define mock.On call

  • ctx context.Context
  • key string
  • value interface{}

func (*MockGenericCache_Expecter) Set

func (_e *MockGenericCache_Expecter) Set(ctx interface{}, key interface{}, value interface{}, ttl interface{}) *MockGenericCache_Set_Call

Set is a helper method to define mock.On call

  • ctx context.Context
  • key string
  • value interface{}
  • ttl time.Duration

type MockGenericCache_Get_Call

type MockGenericCache_Get_Call struct {
	*mock.Call
}

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

func (*MockGenericCache_Get_Call) Return

func (*MockGenericCache_Get_Call) Run

func (_c *MockGenericCache_Get_Call) Run(run func(ctx context.Context, key string, value interface{})) *MockGenericCache_Get_Call

type MockGenericCache_Set_Call

type MockGenericCache_Set_Call struct {
	*mock.Call
}

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

func (*MockGenericCache_Set_Call) Return

func (*MockGenericCache_Set_Call) Run

func (_c *MockGenericCache_Set_Call) Run(run func(ctx context.Context, key string, value interface{}, ttl time.Duration)) *MockGenericCache_Set_Call

type Redis

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

func NewRedisCache

func NewRedisCache(cli *redis.Client) Redis

func (Redis) Get

func (c Redis) Get(ctx context.Context, key string, value interface{}) (bool, error)

func (Redis) Set

func (c Redis) Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error

Jump to

Keyboard shortcuts

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