cache

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CacheMockGetProxyContext = func() (pctx inject.ProxyContext) {
		pctx = cacheMockCommonProxyContext
		pctx.MethodName = "Get"
		return
	}()
	CacheMockLookupProxyContext = func() (pctx inject.ProxyContext) {
		pctx = cacheMockCommonProxyContext
		pctx.MethodName = "Lookup"
		return
	}()
	CacheMockSetProxyContext = func() (pctx inject.ProxyContext) {
		pctx = cacheMockCommonProxyContext
		pctx.MethodName = "Set"
		return
	}()
	CacheMockSetNXProxyContext = func() (pctx inject.ProxyContext) {
		pctx = cacheMockCommonProxyContext
		pctx.MethodName = "SetNX"
		return
	}()
)
View Source
var (
	CacheMockMockGetProxyContext = func() (pctx inject.ProxyContext) {
		pctx = cacheMockMockCommonProxyContext
		pctx.MethodName = "Get"
		return
	}()
	CacheMockMockLookupProxyContext = func() (pctx inject.ProxyContext) {
		pctx = cacheMockMockCommonProxyContext
		pctx.MethodName = "Lookup"
		return
	}()
	CacheMockMockSetProxyContext = func() (pctx inject.ProxyContext) {
		pctx = cacheMockMockCommonProxyContext
		pctx.MethodName = "Set"
		return
	}()
	CacheMockMockSetNXProxyContext = func() (pctx inject.ProxyContext) {
		pctx = cacheMockMockCommonProxyContext
		pctx.MethodName = "SetNX"
		return
	}()
)

Functions

func RegisterProxyMethod added in v0.12.0

func RegisterProxyMethod(pctx inject.ProxyContext, cf inject.CtxFunc)

Types

type Cache

type Cache interface {
	Get(key string) any
	Lookup(key string) (any, bool)
	Set(key string, value any) bool
	SetNX(key string, value any, expire time.Duration) bool
}

Cache 缓存

func New

func New(opt Option) Cache

New 新建

type CacheMock added in v0.5.0

type CacheMock struct {
	GetFunc func(key string) any

	LookupFunc func(key string) (any, bool)

	SetFunc func(key string, value any) bool

	SetNXFunc func(key string, value any, expire time.Duration) bool
}

func (*CacheMock) Get added in v0.5.0

func (mockRecv *CacheMock) Get(key string) any

func (*CacheMock) Lookup added in v0.5.0

func (mockRecv *CacheMock) Lookup(key string) (any, bool)

func (*CacheMock) Set added in v0.5.0

func (mockRecv *CacheMock) Set(key string, value any) bool

func (*CacheMock) SetNX added in v0.5.0

func (mockRecv *CacheMock) SetNX(key string, value any, expire time.Duration) bool

type CacheMockMock added in v0.5.0

type CacheMockMock struct {
	GetFunc func(key string) any

	LookupFunc func(key string) (any, bool)

	SetFunc func(key string, value any) bool

	SetNXFunc func(key string, value any, expire time.Duration) bool
}

func (*CacheMockMock) Get added in v0.5.0

func (mockRecv *CacheMockMock) Get(key string) any

func (*CacheMockMock) Lookup added in v0.5.0

func (mockRecv *CacheMockMock) Lookup(key string) (any, bool)

func (*CacheMockMock) Set added in v0.5.0

func (mockRecv *CacheMockMock) Set(key string, value any) bool

func (*CacheMockMock) SetNX added in v0.5.0

func (mockRecv *CacheMockMock) SetNX(key string, value any, expire time.Duration) bool

type ICacheMock added in v0.5.0

type ICacheMock interface {
	Get(key string) any
	Lookup(key string) (any, bool)
	Set(key string, value any) bool
	SetNX(key string, value any, expire time.Duration) bool
}

type ImemImpl added in v0.5.0

type ImemImpl interface {
	Get(key string) any
	Lookup(key string) (any, bool)
	Set(key string, value any) bool
	SetNX(key string, value any, expire time.Duration) bool
}

type ImemImplMock added in v0.5.0

type ImemImplMock interface {
	Get(key string) any
	Lookup(key string) (any, bool)
	Set(key string, value any) bool
	SetNX(key string, value any, expire time.Duration) bool
}

type Option

type Option struct {
	Type Type // 类型:1 内存;2 redis;
}

Option 选项

type Type

type Type int

Type 缓存类型

const (
	TypeMem Type = iota + 1
	TypeRedis
)

缓存类型枚举

Jump to

Keyboard shortcuts

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