cache

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

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

Go to latest
Published: Apr 21, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cacher

type Cacher interface {
	// Has determines if an entry exists in the cache.
	Has(key string) (bool, error)

	// Get retrieves an entry from the cache for the given key.
	Get(key string) ([]byte, error)

	// GetWithDefault retrieves an entry from the cache for the
	// given key. Returns default value if value is not found.
	GetWithDefault(key string, defaultValue []byte) ([]byte, error)

	// Many retrieves multiple db from the cache by key.
	// Items not found in the cache will have a empty string.
	Many(keys []string) ([][]byte, error)

	// Set stores an entry in the cache for a given number of ttl.
	Set(key string, value []byte, ttl time.Duration) error

	// Pull retrieves an entry from the cache and removes it in the cache.
	Pull(key string) ([]byte, error)

	// PullWithDefault retrieves an entry from the cache and removes it in
	// the cache. Returns default value if value is not found.
	PullWithDefault(key string, defaultValue []byte) ([]byte, error)

	// Forever stores an entry in the cache indefinitely.
	Forever(key string, value []byte) error

	// Remember gets an entry from the cache, or stores an entry from
	// the closure in the cache for a given number of ttl.
	Remember(key string, ttl time.Duration, valueFunc func() ([]byte, error)) ([]byte, error)

	// RememberForever gets an entry from the cache, or stores an entry
	// from the closure in the cache forever.
	RememberForever(key string, valueFunc func() ([]byte, error)) ([]byte, error)

	// Delete removes an entry from the cache.
	Delete(key string) error

	// Reset removes all data from the cache.
	Reset() error

	// Close closes the cache
	Close() error
	// contains filtered or unexported methods
}

Cacher interface defines cache behaviors.

func Storage

func Storage(name ...string) Cacher

Storage gets cache storage by specific name or fallback.

type Cmdable

type Cmdable interface {
	Del(ctx context.Context, keys ...string) *redis.IntCmd
	Exists(ctx context.Context, keys ...string) *redis.IntCmd
	Get(ctx context.Context, key string) *redis.StringCmd
	MGet(ctx context.Context, keys ...string) *redis.SliceCmd
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	Scan(ctx context.Context, cursor uint64, match string, count int64) *redis.ScanCmd
}

Cmdable is a subset of go-redis Cmdable

type Module

type Module struct {
	dawn.Module
	// contains filtered or unexported fields
}

func New

func New() *Module

New returns the Module

func (*Module) Boot

func (m *Module) Boot()

func (*Module) Init

func (m *Module) Init() dawn.Cleanup

func (*Module) String

func (m *Module) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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