Documentation ¶
Index ¶
- Constants
- Variables
- func NewMemoryCache(params ...interface{}) (interface{}, error)
- func NewRedisCache(params ...interface{}) (interface{}, error)
- type GocoreRedisCache
- func (r *GocoreRedisCache) Calc(ctx context.Context, key string, step int64) (int64, error)
- func (r *GocoreRedisCache) Decrement(ctx context.Context, key string) (int64, error)
- func (r *GocoreRedisCache) Del(ctx context.Context, key string) error
- func (r *GocoreRedisCache) DelMany(ctx context.Context, keys []string) error
- func (r *GocoreRedisCache) Get(ctx context.Context, key string) (string, error)
- func (r *GocoreRedisCache) GetMany(ctx context.Context, keys []string) (map[string]string, error)
- func (r *GocoreRedisCache) GetObj(ctx context.Context, key string, model interface{}) error
- func (r *GocoreRedisCache) GetTTL(ctx context.Context, key string) (time.Duration, error)
- func (r *GocoreRedisCache) Increment(ctx context.Context, key string) (int64, error)
- func (r *GocoreRedisCache) Remember(ctx context.Context, key string, timeout time.Duration, ...) error
- func (r *GocoreRedisCache) Set(ctx context.Context, key string, val string, timeout time.Duration) error
- func (r *GocoreRedisCache) SetForever(ctx context.Context, key string, val string) error
- func (r *GocoreRedisCache) SetForeverObj(ctx context.Context, key string, val interface{}) error
- func (r *GocoreRedisCache) SetMany(ctx context.Context, data map[string]string, timeout time.Duration) error
- func (r *GocoreRedisCache) SetObj(ctx context.Context, key string, val interface{}, timeout time.Duration) error
- func (r *GocoreRedisCache) SetTTL(ctx context.Context, key string, timeout time.Duration) error
- type MemoryCache
- func (m *MemoryCache) Calc(ctx context.Context, key string, step int64) (int64, error)
- func (m *MemoryCache) Decrement(ctx context.Context, key string) (int64, error)
- func (m *MemoryCache) Del(ctx context.Context, key string) error
- func (m *MemoryCache) DelMany(ctx context.Context, keys []string) error
- func (m *MemoryCache) Get(ctx context.Context, key string) (string, error)
- func (m *MemoryCache) GetMany(ctx context.Context, keys []string) (map[string]string, error)
- func (m *MemoryCache) GetObj(ctx context.Context, key string, obj interface{}) error
- func (m *MemoryCache) GetTTL(ctx context.Context, key string) (time.Duration, error)
- func (m *MemoryCache) Increment(ctx context.Context, key string) (int64, error)
- func (m *MemoryCache) Remember(ctx context.Context, key string, timeout time.Duration, ...) error
- func (m *MemoryCache) Set(ctx context.Context, key string, val string, timeout time.Duration) error
- func (m *MemoryCache) SetForever(ctx context.Context, key string, val string) error
- func (m *MemoryCache) SetForeverObj(ctx context.Context, key string, val interface{}) error
- func (m *MemoryCache) SetMany(ctx context.Context, data map[string]string, timeout time.Duration) error
- func (m *MemoryCache) SetObj(ctx context.Context, key string, val interface{}, timeout time.Duration) error
- func (m *MemoryCache) SetTTL(ctx context.Context, key string, timeout time.Duration) error
- type MemoryData
Constants ¶
View Source
const (
NoneDuration = time.Duration(-1)
)
Variables ¶
View Source
var ErrKeyNotFound = errors.New("key not found")
View Source
var ErrTypeNotOk = errors.New("val type not ok")
Functions ¶
func NewMemoryCache ¶
func NewMemoryCache(params ...interface{}) (interface{}, error)
func NewRedisCache ¶
func NewRedisCache(params ...interface{}) (interface{}, error)
Types ¶
type GocoreRedisCache ¶
type GocoreRedisCache struct {
// contains filtered or unexported fields
}
func (*GocoreRedisCache) Del ¶
func (r *GocoreRedisCache) Del(ctx context.Context, key string) error
func (*GocoreRedisCache) DelMany ¶
func (r *GocoreRedisCache) DelMany(ctx context.Context, keys []string) error
func (*GocoreRedisCache) GetObj ¶
func (r *GocoreRedisCache) GetObj(ctx context.Context, key string, model interface{}) error
GetObj 获取某个key对应的对象, 对象必须实现 https://pkg.go.dev/encoding#BinaryUnMarshaler
func (*GocoreRedisCache) Remember ¶
func (r *GocoreRedisCache) Remember(ctx context.Context, key string, timeout time.Duration, rememberFunc contract.RememberFunc, obj interface{}) error
func (*GocoreRedisCache) Set ¶
func (r *GocoreRedisCache) Set(ctx context.Context, key string, val string, timeout time.Duration) error
Set 设置某个key和值到缓存,带超时时间
func (*GocoreRedisCache) SetForever ¶
func (*GocoreRedisCache) SetForeverObj ¶
func (r *GocoreRedisCache) SetForeverObj(ctx context.Context, key string, val interface{}) error
func (*GocoreRedisCache) SetMany ¶
func (r *GocoreRedisCache) SetMany(ctx context.Context, data map[string]string, timeout time.Duration) error
SetMany 设置多个key和值到缓存
func (*GocoreRedisCache) SetObj ¶
func (r *GocoreRedisCache) SetObj(ctx context.Context, key string, val interface{}, timeout time.Duration) error
SetObj 设置某个key和对象到缓存, 对象必须实现 https://pkg.go.dev/encoding#BinaryMarshaler
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
func (*MemoryCache) DelMany ¶
func (m *MemoryCache) DelMany(ctx context.Context, keys []string) error
func (*MemoryCache) GetObj ¶
func (m *MemoryCache) GetObj(ctx context.Context, key string, obj interface{}) error
GetObj 获取json对象
func (*MemoryCache) Remember ¶
func (m *MemoryCache) Remember(ctx context.Context, key string, timeout time.Duration, rememberFunc contract.RememberFunc, obj interface{}) error
func (*MemoryCache) SetForever ¶
func (*MemoryCache) SetForeverObj ¶
func (m *MemoryCache) SetForeverObj(ctx context.Context, key string, val interface{}) error
type MemoryData ¶
type MemoryData struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.