Documentation
¶
Index ¶
- Variables
- func RestRedisInstance()
- 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]) RPush(key string, value T) error
- func (g *GoCache[T]) Set(key string, value T, expiration time.Duration) error
- 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]) RPush(key string, value T) error
- func (c *JSONFileCache[T]) Set(key string, value T, expiration time.Duration) error
- type LoaderFunc
- type Queue
- type RedisCache
- func (r *RedisCache[T]) BRPop(timeout time.Duration, key 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]) Incr(key string) (int64, error)
- func (r *RedisCache[T]) IsInitialized() bool
- func (r *RedisCache[T]) RPush(key string, value T) error
- func (r *RedisCache[T]) Set(key string, value T, expiration time.Duration) error
- type RedisConfig
- 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 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 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]) 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 RedisCache ¶
var (
RedisInstance *RedisCache[any]
)
func GetRedisInstance ¶
func GetRedisInstance[T any](r ...*RedisCache[T]) *RedisCache[T]
func NewRedisCache ¶
func NewRedisCache[T any](cfg RedisConfig) (*RedisCache[T], error)
func (*RedisCache[T]) BRPop ¶ added in v0.0.11
func (r *RedisCache[T]) BRPop(timeout time.Duration, key 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]) 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]) RPush ¶ added in v0.0.11
func (r *RedisCache[T]) RPush(key string, value T) error
type RedisConfig ¶
RedisConfig holds the Redis configuration parameters
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.