Documentation ¶
Index ¶
- Variables
- func Delete(k []byte) error
- func Get(k []byte) ([]byte, error)
- func GetSet(k []byte, v []byte, e time.Duration) ([]byte, error)
- func GetWithDataLoad(k []byte, e time.Duration, fn ...func(k []byte) (v []byte, err error)) ([]byte, error)
- func Init(opts ...Option) error
- func New(opts ...Option) (*xcache, error)
- func Set(k []byte, v []byte, e time.Duration) error
- type IXCache
- type MemClearStrategy
- type Option
- func WithBreakdownStrategy(breakdownStrategy func([]byte, []byte, time.Duration) ([]byte, time.Duration)) Option
- func WithClearNum(clearRate float32) Option
- func WithClearTime(clearTime time.Duration) Option
- func WithDataLoadTime(mataLoadTime time.Duration) Option
- func WithDefaultExpiration(defaultExpiration time.Duration) Option
- func WithMaxDataSize(maxDataSize int) Option
- func WithMaxExpiration(maxExpiration time.Duration) Option
- func WithMinBufSize(minBufSize int) Option
- func WithMinDataSize(minDataSize int) Option
- func WithMinExpiration(minExpiration time.Duration) Option
- func WithPenetrateStrategy(...) Option
- func WithSnowSlideStrategy(snowSlideStrategy func(expired time.Duration) time.Duration) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrXCache ... ErrXCache = xerror.New("xcache error") // ErrKeyNotFound ... ErrKeyNotFound = ErrXCache.New("key不存在") // ErrLength ... ErrLength = ErrXCache.New("数据超过了最大的长度限度或者小于最小的长度限度") // ErrBufSize ... ErrBufSize = ErrXCache.New("现有的缓存超过了最大的限度或者小于最小的限度") // ErrBufExceeded ... ErrBufExceeded = ErrXCache.New("现有的缓存超过了最大的缓存限制") // ErrExpiration ... ErrExpiration = ErrXCache.New("过期时间超过了最大的过期时间或者小于最小的过期时间") // ErrClearTime ... ErrClearTime = ErrXCache.New("定时清理过期缓存时间错误") ErrClearNum = ErrXCache.New("定时清理过期缓存数量错误") // ErrDataLoadTime ... ErrDataLoadTime = ErrXCache.New("数据加载函数时间设置错误") // ErrDataLoadTimeout... ErrDataLoadTimeout = ErrXCache.New("数据加载超时") )
Functions ¶
func GetWithDataLoad ¶
Types ¶
type IXCache ¶
type IXCache interface { Set(k, v []byte, e time.Duration) error Get(k []byte) ([]byte, error) GetSet(k, v []byte, e time.Duration) ([]byte, error) GetWithDataLoad(k []byte, e time.Duration, fn ...func(k []byte) (v []byte, err error)) ([]byte, error) Delete(k []byte) error DeleteExpired() error Init(opts ...Option) error Option() Options }
ICache
type MemClearStrategy ¶
type MemClearStrategy uint8
type Option ¶
type Option func(o *Options)
Option 可选配置
func WithBreakdownStrategy ¶
func WithClearNum ¶
func WithDataLoadTime ¶
WithDataLoadTime ...
func WithDefaultExpiration ¶
WithDefaultExpiration ...
func WithMaxExpiration ¶
WithMaxExpiration ...
func WithMinExpiration ¶
WithMinExpiration ...
func WithPenetrateStrategy ¶
type Options ¶
type Options struct { DefaultExpiration time.Duration MinExpiration time.Duration MaxExpiration time.Duration MinBufSize int MaxBufSize uint32 MinDataSize int MaxDataSize int MaxKeySize int DataLoadTime time.Duration ClearTime time.Duration ClearRate float32 Delimiter string // 定期清理时间 Interval time.Duration // 防止雪崩策略 SnowSlideStrategy func(expired time.Duration) time.Duration // 防止穿透策略 PenetrateStrategy func(k []byte, fn ...func(k []byte) ([]byte, error)) ([]byte, error) // 防止击穿策略 BreakdownStrategy func([]byte, []byte, time.Duration) ([]byte, time.Duration) }
Options 缓存配置变量
Source Files ¶
Click to show internal directories.
Click to hide internal directories.