cache

package module
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 10 Imported by: 4

README

Cache component for Enorith

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultExpiration = time.Minute * 20
	CleanupInterval   = time.Minute * 10
)

Functions

func RealKey added in v0.0.3

func RealKey(k string) string

func RegisterDriver

func RegisterDriver(name string, register DriverRegister)

Types

type CacheAble

type CacheAble interface {
	MarshalToCache() interface{}
	UnmarshalFromCache(decoder func(value interface{}) bool) bool
}

type DriverRegister

type DriverRegister func() (Repository, error)

func GetDriverRegister added in v0.0.5

func GetDriverRegister(driver string) (DriverRegister, bool)

type GoCache

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

func NewGoCache

func NewGoCache(gc *gc.Cache, prefix ...string) *GoCache

func (*GoCache) Add

func (c *GoCache) Add(key string, data interface{}, d time.Duration) bool

func (*GoCache) Decrement

func (c *GoCache) Decrement(key string) bool

func (*GoCache) Forever

func (c *GoCache) Forever(key string, data interface{}) error

func (*GoCache) Get

func (c *GoCache) Get(key string, object interface{}) (Value, bool)

func (*GoCache) Has

func (c *GoCache) Has(key string) bool

func (*GoCache) Increment

func (c *GoCache) Increment(key string) bool

func (*GoCache) Put

func (c *GoCache) Put(key string, data interface{}, d time.Duration) error

func (*GoCache) Remove

func (c *GoCache) Remove(key string) bool

type Manager

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

func NewManager

func NewManager(defaultDriver ...string) *Manager

func (*Manager) Add

func (m *Manager) Add(key string, data interface{}, d time.Duration) bool

func (*Manager) Decrement

func (m *Manager) Decrement(key string) bool

func (*Manager) Forever

func (m *Manager) Forever(key string, data interface{}) error

func (*Manager) Get

func (m *Manager) Get(key string, object interface{}) (Value, bool)

func (*Manager) GetRepository added in v0.0.7

func (m *Manager) GetRepository(driver string) (Repository, bool)

func (*Manager) Has

func (m *Manager) Has(key string) bool

func (*Manager) Increment

func (m *Manager) Increment(key string) bool

func (*Manager) Put

func (m *Manager) Put(key string, data interface{}, d time.Duration) error

func (*Manager) Remove

func (m *Manager) Remove(key string) bool

func (*Manager) Use

func (m *Manager) Use(driver string) error

type RedisCache

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

func NewRedisCache

func NewRedisCache(options *cache.Options, prefix ...string) *RedisCache

func (*RedisCache) Add

func (r *RedisCache) Add(key string, data interface{}, d time.Duration) bool

func (*RedisCache) Decrement

func (r *RedisCache) Decrement(key string) bool

func (*RedisCache) Forever

func (r *RedisCache) Forever(key string, data interface{}) error

func (*RedisCache) Get

func (r *RedisCache) Get(key string, object interface{}) (Value, bool)

func (*RedisCache) Has

func (r *RedisCache) Has(key string) bool

func (*RedisCache) Increment

func (r *RedisCache) Increment(key string) bool

func (*RedisCache) NativeCall

func (r *RedisCache) NativeCall(f func(c RedisClient) error) error

func (*RedisCache) Put

func (r *RedisCache) Put(key string, data interface{}, d time.Duration) error

func (*RedisCache) Remove

func (r *RedisCache) Remove(key string) bool

type RedisClient

type RedisClient interface {
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	Incr(ctx context.Context, key string) *redis.IntCmd
	Decr(ctx context.Context, key string) *redis.IntCmd
	Get(ctx context.Context, key string) *redis.StringCmd
	Do(ctx context.Context, args ...interface{}) *redis.Cmd
}

type Repository

type Repository interface {
	Has(key string) bool
	Get(key string, object interface{}) (Value, bool)
	Put(key string, data interface{}, d time.Duration) error
	Forever(key string, data interface{}) error
	Remove(key string) bool
	Increment(key string) bool
	Decrement(key string) bool
	Add(key string, data interface{}, d time.Duration) bool
}

type Value

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

func (*Value) Data

func (v *Value) Data() interface{}

func (*Value) MarshalJSON

func (v *Value) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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