Documentation
¶
Index ¶
- Variables
- func RestRedisInstance()
- type Agg
- type AggField
- type Cache
- type GoCache
- func (g *GoCache[T]) BRPop(timeout time.Duration, key string) (T, error)
- func (g *GoCache[T]) Del(key string) error
- func (g *GoCache[T]) Exists(key string) (bool, error)
- func (g *GoCache[T]) Expire(key string, expiration time.Duration) error
- func (g *GoCache[T]) Flush() error
- func (g *GoCache[T]) Get(key string) (T, error)
- func (g *GoCache[T]) Incr(key string) (int64, error)
- func (g *GoCache[T]) IsInitialized() bool
- func (g *GoCache[T]) Items() map[string]T
- func (g *GoCache[T]) Keys() ([]string, error)
- func (g *GoCache[T]) RPush(key string, value T) error
- func (g *GoCache[T]) Set(key string, value T, expiration time.Duration) error
- type Granularity
- type JSONFileCache
- func (c *JSONFileCache[T]) BRPop(timeout time.Duration, key string) (value T, err error)
- func (c *JSONFileCache[T]) Del(key string) error
- func (c *JSONFileCache[T]) Exists(key string) (bool, error)
- func (c *JSONFileCache[T]) Expire(key string, expiration time.Duration) error
- func (c *JSONFileCache[T]) Flush() error
- func (c *JSONFileCache[T]) Get(key string) (T, error)
- func (c *JSONFileCache[T]) Incr(key string) (int64, error)
- func (c *JSONFileCache[T]) IsInitialized() bool
- func (c *JSONFileCache[T]) Items() map[string]T
- func (c *JSONFileCache[T]) Keys() ([]string, error)
- func (c *JSONFileCache[T]) RPush(key string, value T) error
- func (c *JSONFileCache[T]) Set(key string, value T, expiration time.Duration) error
- type LoaderFunc
- type PageCache
- type PageGroupItem
- type PageSorter
- type PageTimeItem
- type Pager
- type Queue
- type RedisCache
- func (r *RedisCache[T]) AddDelayed(queue string, value T, score float64) error
- func (r *RedisCache[T]) BRPop(timeout time.Duration, queue string) (value T, err error)
- func (r *RedisCache[T]) BRPopCtx(ctx context.Context, timeout time.Duration, queue string) (value T, err error)
- func (r *RedisCache[T]) Del(key string) error
- func (r *RedisCache[T]) Exists(key string) (bool, error)
- func (r *RedisCache[T]) Expire(key string, expiration time.Duration) error
- func (r *RedisCache[T]) Flush() error
- func (r *RedisCache[T]) Get(key string) (T, error)
- func (r *RedisCache[T]) GetCtx() context.Context
- func (r *RedisCache[T]) Incr(key string) (int64, error)
- func (r *RedisCache[T]) IsInitialized() bool
- func (r *RedisCache[T]) Items() map[string]T
- func (r *RedisCache[T]) Keys() ([]string, error)
- func (r *RedisCache[T]) LPop(queue string) (value T, err error)
- func (r *RedisCache[T]) PopDueDelayed(queue string, now float64, limit int) ([]T, error)
- func (r *RedisCache[T]) RPush(queue string, value T) error
- func (r *RedisCache[T]) Set(key string, value T, expiration time.Duration) error
- type RedisConfig
- type SQLiteCache
- func (c *SQLiteCache[T]) BRPop(sqliteTimeOut time.Duration, key string) (T, error)
- func (c *SQLiteCache[T]) Del(key string) error
- func (c *SQLiteCache[T]) Exists(key string) (bool, error)
- func (c *SQLiteCache[T]) Expire(key string, expiration time.Duration) error
- func (c *SQLiteCache[T]) Flush() error
- func (c *SQLiteCache[T]) Get(key string) (T, error)
- func (c *SQLiteCache[T]) Incr(key string) (int64, error)
- func (c *SQLiteCache[T]) IsInitialized() bool
- func (c *SQLiteCache[T]) Items() map[string]T
- func (c *SQLiteCache[T]) Keys() ([]string, error)
- func (c *SQLiteCache[T]) RPush(key string, value T) error
- func (c *SQLiteCache[T]) Set(key string, value T, expiration time.Duration) error
- type SQLiteCachePage
- func (c *SQLiteCachePage[T]) Count(conditions map[string]any) (int64, error)
- func (c *SQLiteCachePage[T]) Delete(conditions map[string]any) error
- func (c *SQLiteCachePage[T]) Find(page, size int64, conditions map[string]any, sorts ...PageSorter) (*PageCache[T], error)
- func (c *SQLiteCachePage[T]) Get(conditions map[string]any) (*T, error)
- func (c *SQLiteCachePage[T]) GroupByFields(conditions map[string]any, groupFields []string, aggFields []AggField, ...) (*PageCache[PageGroupItem], error)
- func (c *SQLiteCachePage[T]) GroupByTime(conditions map[string]any, from, to time.Time, granularity Granularity, ...) ([]*PageTimeItem, error)
- func (c *SQLiteCachePage[T]) Put(value T) error
- func (c *SQLiteCachePage[T]) Update(conditions map[string]any, value *T) error
- type Tool
- type Type
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCacheMiss = errors.New("cache miss")
ErrCacheMiss indicates a cache miss error
View Source
var SimpleTool = func(ctx *gin.Context) *Tool[any] { return NewCacheTool[any](ctx, caches, nil) }
Functions ¶
func RestRedisInstance ¶ added in v0.0.11
func RestRedisInstance()
Types ¶
type Cache ¶
type Cache[T any] interface { IsInitialized() bool Keys() ([]string, error) Items() map[string]T Get(key string) (T, error) Set(key string, value T, expiration time.Duration) error Del(key string) error Exists(key string) (bool, error) RPush(key string, value T) error BRPop(timeout time.Duration, key string) (value T, err error) Incr(key string) (int64, error) Expire(key string, expiration time.Duration) error Flush() error }
Cache is a generic cache interface that defines basic cache operations
type GoCache ¶
type GoCache[T any] struct { // contains filtered or unexported fields }
func NewGoCache ¶
func (*GoCache[T]) IsInitialized ¶ added in v0.0.11
type Granularity ¶ added in v0.0.44
type Granularity string
const ( GranularityMinute Granularity = "minute" GranularityHour Granularity = "hour" GranularityDay Granularity = "day" GranularityWeek Granularity = "week" GranularityMonth Granularity = "month" GranularityYear Granularity = "year" Granularity5Minutes Granularity = "5m" Granularity10Minutes Granularity = "10m" Granularity30Minutes Granularity = "30m" )
type JSONFileCache ¶ added in v0.0.33
type JSONFileCache[T any] struct { // contains filtered or unexported fields }
func NewJSONCache ¶ added in v0.0.33
func NewJSONCache[T any](cacheType string) (*JSONFileCache[T], error)
func (*JSONFileCache[T]) BRPop ¶ added in v0.0.33
func (c *JSONFileCache[T]) BRPop(timeout time.Duration, key string) (value T, err error)
func (*JSONFileCache[T]) Del ¶ added in v0.0.33
func (c *JSONFileCache[T]) Del(key string) error
func (*JSONFileCache[T]) Exists ¶ added in v0.0.33
func (c *JSONFileCache[T]) Exists(key string) (bool, error)
func (*JSONFileCache[T]) Expire ¶ added in v0.0.33
func (c *JSONFileCache[T]) Expire(key string, expiration time.Duration) error
func (*JSONFileCache[T]) Flush ¶ added in v0.0.33
func (c *JSONFileCache[T]) Flush() error
func (*JSONFileCache[T]) Get ¶ added in v0.0.33
func (c *JSONFileCache[T]) Get(key string) (T, error)
func (*JSONFileCache[T]) Incr ¶ added in v0.0.33
func (c *JSONFileCache[T]) Incr(key string) (int64, error)
func (*JSONFileCache[T]) IsInitialized ¶ added in v0.0.33
func (c *JSONFileCache[T]) IsInitialized() bool
func (*JSONFileCache[T]) Items ¶ added in v0.0.49
func (c *JSONFileCache[T]) Items() map[string]T
func (*JSONFileCache[T]) Keys ¶ added in v0.0.49
func (c *JSONFileCache[T]) Keys() ([]string, error)
func (*JSONFileCache[T]) RPush ¶ added in v0.0.33
func (c *JSONFileCache[T]) RPush(key string, value T) error
type LoaderFunc ¶
LoaderFunc is a function type for loading data from an external source
type PageCache ¶ added in v0.0.36
type PageGroupItem ¶ added in v0.0.49
type PageSorter ¶ added in v0.0.36
func PageSorterAsc ¶ added in v0.0.36
func PageSorterAsc(field string) PageSorter
func PageSorterDesc ¶ added in v0.0.36
func PageSorterDesc(field string) PageSorter
type PageTimeItem ¶ added in v0.0.44
type Pager ¶ added in v0.0.44
type Pager[T any] interface { Put(value T) error Find(page, size int64, conditions map[string]any, sort ...PageSorter) (*PageCache[T], error) Get(conditions map[string]any) (*T, error) Count(conditions map[string]any) (int64, error) Update(conditions map[string]any, value *T) error Delete(conditions map[string]any) error GroupByTime(conditions map[string]any, from, to time.Time, granularity Granularity, agg Agg, fields ...string) ([]*PageTimeItem, error) GroupByFields(conditions map[string]any, groupFields []string, aggFields []AggField, page, size int64, sorts ...PageSorter) (*PageCache[PageGroupItem], error) }
type RedisCache ¶
func GetRedisInstance ¶
func GetRedisInstance[T any](ctx context.Context) *RedisCache[T]
func (*RedisCache[T]) AddDelayed ¶ added in v0.0.49
func (r *RedisCache[T]) AddDelayed(queue string, value T, score float64) error
func (*RedisCache[T]) BRPop ¶ added in v0.0.11
func (r *RedisCache[T]) BRPop(timeout time.Duration, queue string) (value T, err error)
func (*RedisCache[T]) Del ¶ added in v0.0.11
func (r *RedisCache[T]) Del(key string) error
func (*RedisCache[T]) Exists ¶ added in v0.0.11
func (r *RedisCache[T]) Exists(key string) (bool, error)
func (*RedisCache[T]) Expire ¶ added in v0.0.11
func (r *RedisCache[T]) Expire(key string, expiration time.Duration) error
func (*RedisCache[T]) Flush ¶ added in v0.0.33
func (r *RedisCache[T]) Flush() error
func (*RedisCache[T]) Get ¶
func (r *RedisCache[T]) Get(key string) (T, error)
func (*RedisCache[T]) GetCtx ¶ added in v0.0.48
func (r *RedisCache[T]) GetCtx() context.Context
func (*RedisCache[T]) Incr ¶ added in v0.0.11
func (r *RedisCache[T]) Incr(key string) (int64, error)
func (*RedisCache[T]) IsInitialized ¶ added in v0.0.11
func (r *RedisCache[T]) IsInitialized() bool
func (*RedisCache[T]) Items ¶ added in v0.0.49
func (r *RedisCache[T]) Items() map[string]T
func (*RedisCache[T]) Keys ¶ added in v0.0.49
func (r *RedisCache[T]) Keys() ([]string, error)
func (*RedisCache[T]) LPop ¶ added in v0.0.49
func (r *RedisCache[T]) LPop(queue string) (value T, err error)
func (*RedisCache[T]) PopDueDelayed ¶ added in v0.0.49
func (r *RedisCache[T]) PopDueDelayed(queue string, now float64, limit int) ([]T, error)
func (*RedisCache[T]) RPush ¶ added in v0.0.11
func (r *RedisCache[T]) RPush(queue string, value T) error
type RedisConfig ¶
RedisConfig holds the Redis configuration parameters
type SQLiteCache ¶ added in v0.0.36
type SQLiteCache[T any] struct { // contains filtered or unexported fields }
func NewSQLiteCache ¶ added in v0.0.36
func NewSQLiteCache[T any](cacheType string) (*SQLiteCache[T], error)
func (*SQLiteCache[T]) BRPop ¶ added in v0.0.36
func (c *SQLiteCache[T]) BRPop(sqliteTimeOut time.Duration, key string) (T, error)
func (*SQLiteCache[T]) Del ¶ added in v0.0.36
func (c *SQLiteCache[T]) Del(key string) error
func (*SQLiteCache[T]) Exists ¶ added in v0.0.36
func (c *SQLiteCache[T]) Exists(key string) (bool, error)
func (*SQLiteCache[T]) Expire ¶ added in v0.0.36
func (c *SQLiteCache[T]) Expire(key string, expiration time.Duration) error
func (*SQLiteCache[T]) Flush ¶ added in v0.0.36
func (c *SQLiteCache[T]) Flush() error
func (*SQLiteCache[T]) Get ¶ added in v0.0.36
func (c *SQLiteCache[T]) Get(key string) (T, error)
func (*SQLiteCache[T]) Incr ¶ added in v0.0.36
func (c *SQLiteCache[T]) Incr(key string) (int64, error)
func (*SQLiteCache[T]) IsInitialized ¶ added in v0.0.36
func (c *SQLiteCache[T]) IsInitialized() bool
func (*SQLiteCache[T]) Items ¶ added in v0.0.49
func (c *SQLiteCache[T]) Items() map[string]T
func (*SQLiteCache[T]) Keys ¶ added in v0.0.49
func (c *SQLiteCache[T]) Keys() ([]string, error)
func (*SQLiteCache[T]) RPush ¶ added in v0.0.36
func (c *SQLiteCache[T]) RPush(key string, value T) error
type SQLiteCachePage ¶ added in v0.0.36
type SQLiteCachePage[T any] struct { // contains filtered or unexported fields }
func NewSQLiteCachePage ¶ added in v0.0.36
func NewSQLiteCachePage[T any](name string) (*SQLiteCachePage[T], error)
NewSQLiteCachePage Create a new SQLite cache page with the given name.
func (*SQLiteCachePage[T]) Count ¶ added in v0.0.36
func (c *SQLiteCachePage[T]) Count(conditions map[string]any) (int64, error)
func (*SQLiteCachePage[T]) Delete ¶ added in v0.0.44
func (c *SQLiteCachePage[T]) Delete(conditions map[string]any) error
func (*SQLiteCachePage[T]) Find ¶ added in v0.0.36
func (c *SQLiteCachePage[T]) Find(page, size int64, conditions map[string]any, sorts ...PageSorter) (*PageCache[T], error)
func (*SQLiteCachePage[T]) Get ¶ added in v0.0.36
func (c *SQLiteCachePage[T]) Get(conditions map[string]any) (*T, error)
func (*SQLiteCachePage[T]) GroupByFields ¶ added in v0.0.49
func (c *SQLiteCachePage[T]) GroupByFields( conditions map[string]any, groupFields []string, aggFields []AggField, page, size int64, sorts ...PageSorter, ) (*PageCache[PageGroupItem], error)
func (*SQLiteCachePage[T]) GroupByTime ¶ added in v0.0.44
func (c *SQLiteCachePage[T]) GroupByTime( conditions map[string]any, from, to time.Time, granularity Granularity, agg Agg, fields ...string, ) ([]*PageTimeItem, error)
func (*SQLiteCachePage[T]) Put ¶ added in v0.0.36
func (c *SQLiteCachePage[T]) Put(value T) error
type Tool ¶
Tool is a management tool for multi-level cache
func NewCacheTool ¶
NewCacheTool creates a new Tool instance
Click to show internal directories.
Click to hide internal directories.