Documentation
¶
Index ¶
- Constants
- Variables
- func ValidateConnectionString(typ CacheType, connStr string) error
- type Cache
- type CacheInstance
- type CacheInstanceCloser
- type CacheInstancePinger
- type CacheOption
- type CacheType
- type ConnectionPassword
- type ConnectionString
- type DefaultTTL
- type ErrKeyNotFound
- type Instrumenter
- type ItemOption
- type KeyPrefix
- type Loader
- type TTL
Constants ¶
View Source
const ( InstrumentationCacheStart = "cache-start" InstrumentationCacheClose = "cache-close" InstrumentationCachePing = "cache-ping" InstrumentationCacheGet = "cache-get" InstrumentationCacheLoader = "cache-loader" InstrumentationCacheSet = "cache-set" InstrumentationCacheDelete = "cache-delete" )
Variables ¶
View Source
var ErrCacheClosed = errors.New("cache closed")
Functions ¶
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 CacheInstance ¶
type CacheInstance[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 }
CacheInstance represents a cache instance.
func Create ¶
func Create[T any](cache *Cache, name string, opts ...CacheOption) (CacheInstance[T], error)
Create new cache instance with specified name and options.
type CacheInstanceCloser ¶
type CacheInstanceCloser interface {
// Close cache instance.
Close()
}
CacheInstanceCloser represents a cache instance close method.
type CacheInstancePinger ¶
CacheInstancePinger represents a cache instance ping method.
type CacheOption ¶
type CacheOption interface {
// contains filtered or unexported methods
}
CacheOption is an option for the cache instance.
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 ErrKeyNotFound ¶
type ErrKeyNotFound struct {
Key string
}
func (ErrKeyNotFound) Error ¶
func (e ErrKeyNotFound) Error() string
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.
Click to show internal directories.
Click to hide internal directories.