cache

package module
v0.0.0-...-9a033ea Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 5 Imported by: 0

README

cache

a effective cache reloader for golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithSource

func WithSource(source ISource) func(*Cache)

func WithTTL

func WithTTL(ttl time.Duration) func(*Cache)

Types

type Cache

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

Cache

func NewCache

func NewCache(opts ...CacheOption) *Cache

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, key string) (interface{}, error)

func (*Cache) RGet

func (c *Cache) RGet(ctx context.Context, key string) *Result

type CacheOption

type CacheOption func(*Cache)

type ICache

type ICache interface {
	Get(ctx context.Context, key string) (interface{}, error)
	Set(ctx context.Context, key string, data interface{}) error
}

ICache

type ISource

type ISource interface {
	Get(ctx context.Context, key string) (interface{}, error)
}

ISource

type MemoryCache

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

func (*MemoryCache) Clear

func (m *MemoryCache) Clear(ctx context.Context, key string)

func (*MemoryCache) Get

func (m *MemoryCache) Get(ctx context.Context, key string) (interface{}, error)

func (*MemoryCache) Set

func (m *MemoryCache) Set(ctx context.Context, key string, data interface{}) error

type MemoryCacheSlot

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

func (MemoryCacheSlot) Data

func (m MemoryCacheSlot) Data() interface{}

func (MemoryCacheSlot) IsExpire

func (m MemoryCacheSlot) IsExpire(ttl time.Duration) bool

type Result

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

func (*Result) Data

func (r *Result) Data() interface{}

func (*Result) Error

func (r *Result) Error() error

func (*Result) Int32

func (r *Result) Int32() int32

func (*Result) Int64

func (r *Result) Int64() int64

func (*Result) String

func (r *Result) String() string

Jump to

Keyboard shortcuts

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