Documentation
¶
Index ¶
- type Cache
- func (c *Cache[T]) Delete(ctx context.Context, field string) error
- func (c *Cache[T]) Exists(ctx context.Context, field string) (bool, error)
- func (c *Cache[T]) Expire(ctx context.Context, field string, expiration time.Duration) error
- func (c *Cache[T]) Get(ctx context.Context, field string) (*T, error)
- func (c *Cache[T]) GetArray(ctx context.Context, field string, dest any) error
- func (c *Cache[T]) GetMultiple(ctx context.Context, fields []string) (map[string]*T, error)
- func (c *Cache[T]) Key(field string) string
- func (c *Cache[T]) Set(ctx context.Context, field string, data *T, expire ...time.Duration) error
- func (c *Cache[T]) SetArray(ctx context.Context, field string, data any, expire ...time.Duration) error
- func (c *Cache[T]) SetMultiple(ctx context.Context, items map[string]*T, expire ...time.Duration) error
- func (c *Cache[T]) TTL(ctx context.Context, field string) (time.Duration, error)
- type ICache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[T any] struct { // contains filtered or unexported fields }
Cache implements the ICache interface
func NewCacheWithMetrics ¶ added in v0.1.4
func NewCacheWithMetrics[T any](rc *redis.Client, key string, collector metrics.CacheMetricsCollector, useHash ...bool) *Cache[T]
NewCacheWithMetrics creates a new Cache instance collector
func (*Cache[T]) GetMultiple ¶ added in v0.1.4
GetMultiple retrieves multiple items from cache
func (*Cache[T]) SetArray ¶
func (c *Cache[T]) SetArray(ctx context.Context, field string, data any, expire ...time.Duration) error
SetArray saves an array of items into cache
type ICache ¶
type ICache[T any] interface { Get(context.Context, string) (*T, error) Set(context.Context, string, *T, ...time.Duration) error Delete(context.Context, string) error GetArray(context.Context, string, any) error SetArray(context.Context, string, any, ...time.Duration) error GetMultiple(context.Context, []string) (map[string]*T, error) SetMultiple(context.Context, map[string]*T, ...time.Duration) error Exists(context.Context, string) (bool, error) TTL(context.Context, string) (time.Duration, error) Expire(context.Context, string, time.Duration) error }
ICache defines a general caching interface
Click to show internal directories.
Click to hide internal directories.