cache

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package cache is a package that unifies the definition of caching, supporting both redis and local caching.

Index

Constants

View Source
const (

	// CacheNameExampleExpireTime expire time
	CacheNameExampleExpireTime = 5 * time.Minute
)
View Source
const (

	// UserExampleExpireTime expire time
	UserExampleExpireTime = 5 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheNameExampleCache

type CacheNameExampleCache interface {
	Set(ctx context.Context, keyNameExample keyTypeExample, valueNameExample valueTypeExample, duration time.Duration) error
	Get(ctx context.Context, keyNameExample keyTypeExample) (valueTypeExample, error)
	Del(ctx context.Context, keyNameExample keyTypeExample) error
}

CacheNameExampleCache cache interface

func NewCacheNameExampleCache

func NewCacheNameExampleCache(cacheType *model.CacheType) CacheNameExampleCache

NewCacheNameExampleCache create a new cache

type UserExampleCache

type UserExampleCache interface {
	Set(ctx context.Context, id uint64, data *model.UserExample, duration time.Duration) error
	Get(ctx context.Context, id uint64) (*model.UserExample, error)
	MultiGet(ctx context.Context, ids []uint64) (map[uint64]*model.UserExample, error)
	MultiSet(ctx context.Context, data []*model.UserExample, duration time.Duration) error
	Del(ctx context.Context, id uint64) error
	SetCacheWithNotFound(ctx context.Context, id uint64) error
}

UserExampleCache cache interface

func NewUserExampleCache

func NewUserExampleCache(cacheType *model.CacheType) UserExampleCache

NewUserExampleCache new a cache

Jump to

Keyboard shortcuts

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