cache

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinUint32 uint32 = 0
	MinUint64 uint64 = 0
)

Variables

View Source
var (
	ErrKeyExpired = errors.New("key expired")

	ErrMultiGetFailed = errors.New("multi get failed")

	ErrIncrementOverflow = errors.New("incream overflow")

	ErrDecrementOverflow = errors.New("cecrement overflow")

	ErrNotIntegerType = errors.New("not integer type")
)

Functions

func Decr added in v0.0.6

func Decr(originVal interface{}) (interface{}, error)

func Incr added in v0.0.6

func Incr(originVal interface{}) (interface{}, error)

Types

type Cache

type Cache interface {
	// Get gets a cached value by key.
	Get(ctx context.Context, key string) (any, error)
	// Fetch is batch version of get
	Fetch(ctx context.Context, key []string) ([]any, error)
	// Put stores a key-value pair into cache.
	Put(ctx context.Context, key string, value any, timeout ...time.Duration) error
	// Delete removes a key from cache.
	Delete(ctx context.Context, key string) error

	IsExist(ctx context.Context, key string) (bool, error)
	ClearAll(ctx context.Context) error

	Incr(ctx context.Context, key string) error
	// Decrement a cached int value by key, as a counter.
	Decr(ctx context.Context, key string) error
}

type Marshaler

type Marshaler interface {
	Marshal() (data []byte, err error)
}

type Unmarshaler

type Unmarshaler interface {
	Unmarshal(data []byte) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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