Documentation ¶
Index ¶
- Constants
- Variables
- func InstrDelete(op string, args ...any) (string, bool)
- func InstrGet(op string, args ...any) (string, bool)
- func InstrLoader(op string, args ...any) (string, bool)
- func InstrSet(op string, args ...any) (string, bool)
- func ParseRedisClusterURL(v string) (*redis.ClusterOptions, error)
- func ParseRedisURL(v string) (*redis.Options, error)
- func ValidateConnectionString(typ Type, connStr string) error
- type Cache
- type ConnectionPassword
- type ConnectionString
- type DefaultTTL
- type Instance
- type InstanceCloser
- type InstancePinger
- type Instrumenter
- type ItemOption
- type KeyNotFoundError
- type KeyPrefix
- type Loader
- type Option
- type TTL
- type Type
Constants ¶
const ( InstrumentationStart = "cache-start" InstrumentationClose = "cache-close" InstrumentationPing = "cache-ping" InstrumentationGet = "cache-get" InstrumentationLoader = "cache-loader" InstrumentationSet = "cache-set" InstrumentationDelete = "cache-delete" )
Variables ¶
var ErrCacheClosed = errors.New("cache closed")
Functions ¶
func InstrDelete ¶ added in v0.15.0
InstrDelete returns cache key if the operation is cache delete event.
func InstrLoader ¶ added in v0.15.0
InstrLoader returns cache key if the operation is cache loader event.
func ParseRedisClusterURL ¶ added in v0.11.0
func ParseRedisURL ¶ added in v0.11.0
func ValidateConnectionString ¶
ValidateConnectionString validates connection string for specific cache type.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache represents a cache.
type ConnectionPassword ¶
type ConnectionPassword string
ConnectionString is a connection password for the cache instance.
type ConnectionString ¶
type ConnectionString string
ConnectionString is a connection string for the cache instance.
type DefaultTTL ¶
DefaultTTL is an default TTL for items in cache instance.
type Instance ¶ added in v0.15.0
type Instance[T any] interface { // Get value from cache. If value is not found, it will return default value. Get(ctx context.Context, key string, opts ...ItemOption[T]) (T, error) // Pop returns value from tha cache and deletes it. If value is not found, it will return ErrKeyNotFound error. Pop(ctx context.Context, key string) (T, error) // Set value in cache. Set(ctx context.Context, key string, value T, opts ...ItemOption[T]) error // Delete value from cache. Delete(ctx context.Context, key string) error }
Instance of a cache.
type InstanceCloser ¶ added in v0.15.0
type InstanceCloser interface {
// Close cache instance.
Close()
}
InstanceCloser represents a cache instance close method.
type InstancePinger ¶ added in v0.15.0
InstancePinger represents a cache instance ping method.
type Instrumenter ¶ added in v0.7.0
type Instrumenter instrumenter.Instrumenter
Instrumenter is a function that instruments cache operations.
type ItemOption ¶
type ItemOption[T any] interface { // contains filtered or unexported methods }
ItemOption is an option for the cached item.
type KeyNotFoundError ¶ added in v0.15.0
type KeyNotFoundError struct {
Key string
}
func (KeyNotFoundError) Error ¶ added in v0.15.0
func (e KeyNotFoundError) Error() string
type Loader ¶
Loader is a function that loads data when cache key is missing.
WARNING: it's not guaranteed that the function will be called only once.
type Option ¶ added in v0.15.0
type Option interface {
// contains filtered or unexported methods
}
Option for the cache instance.