Documentation
¶
Index ¶
- func NewLoggingMiddleware(next hypercache.Service, logger Logger) hypercache.Service
- func NewStatsCollectorMiddleware(next hypercache.Service, statsCollector stats.ICollector) hypercache.Service
- type Logger
- type LoggingMiddleware
- func (mw LoggingMiddleware) Allocation() int64
- func (mw LoggingMiddleware) Capacity() int
- func (mw LoggingMiddleware) Clear(ctx context.Context) error
- func (mw LoggingMiddleware) Count() int
- func (mw LoggingMiddleware) Get(key string) (value interface{}, ok bool)
- func (mw LoggingMiddleware) GetMultiple(ctx context.Context, keys ...string) (result map[string]any, failed map[string]error)
- func (mw LoggingMiddleware) GetOrSet(ctx context.Context, key string, value any, expiration time.Duration) (any, error)
- func (mw LoggingMiddleware) GetStats() stats.Stats
- func (mw LoggingMiddleware) GetWithInfo(key string) (item *types.Item, ok bool)
- func (mw LoggingMiddleware) List(ctx context.Context, filters ...backend.IFilter) ([]*types.Item, error)
- func (mw LoggingMiddleware) Remove(ctx context.Context, keys ...string)
- func (mw LoggingMiddleware) Set(ctx context.Context, key string, value any, expiration time.Duration) error
- func (mw LoggingMiddleware) Stop()
- func (mw LoggingMiddleware) TriggerEviction()
- type StatsCollectorMiddleware
- func (mw StatsCollectorMiddleware) Allocation() int64
- func (mw StatsCollectorMiddleware) Capacity() int
- func (mw StatsCollectorMiddleware) Clear(ctx context.Context) error
- func (mw StatsCollectorMiddleware) Count() int
- func (mw StatsCollectorMiddleware) Get(key string) (interface{}, bool)
- func (mw StatsCollectorMiddleware) GetMultiple(ctx context.Context, keys ...string) (result map[string]any, failed map[string]error)
- func (mw StatsCollectorMiddleware) GetOrSet(ctx context.Context, key string, value any, expiration time.Duration) (any, error)
- func (mw StatsCollectorMiddleware) GetStats() stats.Stats
- func (mw StatsCollectorMiddleware) GetWithInfo(key string) (*types.Item, bool)
- func (mw StatsCollectorMiddleware) List(ctx context.Context, filters ...backend.IFilter) ([]*types.Item, error)
- func (mw StatsCollectorMiddleware) Remove(ctx context.Context, keys ...string)
- func (mw StatsCollectorMiddleware) Set(ctx context.Context, key string, value any, expiration time.Duration) error
- func (mw StatsCollectorMiddleware) Stop()
- func (mw StatsCollectorMiddleware) TriggerEviction()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLoggingMiddleware ¶
func NewLoggingMiddleware(next hypercache.Service, logger Logger) hypercache.Service
NewLoggingMiddleware returns a new LoggingMiddleware.
func NewStatsCollectorMiddleware ¶
func NewStatsCollectorMiddleware(next hypercache.Service, statsCollector stats.ICollector) hypercache.Service
NewStatsCollectorMiddleware returns a new StatsCollectorMiddleware
Types ¶
type Logger ¶
type Logger interface {
Printf(format string, v ...interface{})
}
Logger describes a logging interface allowing to implement different external, or custom logger. Tested with logrus, and Uber's Zap (high-performance), but should work with any other logger that matches the interface.
type LoggingMiddleware ¶
type LoggingMiddleware struct {
// contains filtered or unexported fields
}
LoggingMiddleware is a middleware that logs the time it takes to execute the next middleware. Must implement the hypercache.Service interface.
func (LoggingMiddleware) Allocation ¶ added in v0.1.0
func (mw LoggingMiddleware) Allocation() int64
Allocation returns the size allocation in bytes cache
func (LoggingMiddleware) Capacity ¶
func (mw LoggingMiddleware) Capacity() int
Capacity takes to execute the next middleware.
func (LoggingMiddleware) Clear ¶
func (mw LoggingMiddleware) Clear(ctx context.Context) error
Clear logs the time it takes to execute the next middleware.
func (LoggingMiddleware) Count ¶ added in v0.1.0
func (mw LoggingMiddleware) Count() int
Count takes to execute the next middleware.
func (LoggingMiddleware) Get ¶
func (mw LoggingMiddleware) Get(key string) (value interface{}, ok bool)
Get logs the time it takes to execute the next middleware.
func (LoggingMiddleware) GetMultiple ¶
func (mw LoggingMiddleware) GetMultiple(ctx context.Context, keys ...string) (result map[string]any, failed map[string]error)
GetMultiple logs the time it takes to execute the next middleware.
func (LoggingMiddleware) GetOrSet ¶
func (mw LoggingMiddleware) GetOrSet(ctx context.Context, key string, value any, expiration time.Duration) (any, error)
GetOrSet logs the time it takes to execute the next middleware.
func (LoggingMiddleware) GetStats ¶
func (mw LoggingMiddleware) GetStats() stats.Stats
GetStats logs the time it takes to execute the next middleware.
func (LoggingMiddleware) GetWithInfo ¶ added in v0.1.0
func (mw LoggingMiddleware) GetWithInfo(key string) (item *types.Item, ok bool)
GetWithInfo logs the time it takes to execute the next middleware.
func (LoggingMiddleware) List ¶
func (mw LoggingMiddleware) List(ctx context.Context, filters ...backend.IFilter) ([]*types.Item, error)
List logs the time it takes to execute the next middleware.
func (LoggingMiddleware) Remove ¶
func (mw LoggingMiddleware) Remove(ctx context.Context, keys ...string)
Remove logs the time it takes to execute the next middleware.
func (LoggingMiddleware) Set ¶
func (mw LoggingMiddleware) Set(ctx context.Context, key string, value any, expiration time.Duration) error
Set logs the time it takes to execute the next middleware.
func (LoggingMiddleware) Stop ¶
func (mw LoggingMiddleware) Stop()
Stop logs the time it takes to execute the next middleware.
func (LoggingMiddleware) TriggerEviction ¶
func (mw LoggingMiddleware) TriggerEviction()
TriggerEviction logs the time it takes to execute the next middleware.
type StatsCollectorMiddleware ¶
type StatsCollectorMiddleware struct {
// contains filtered or unexported fields
}
StatsCollectorMiddleware is a middleware that collects stats. It can and should re-use the same stats collector as the hypercache. Must implement the hypercache.Service interface.
func (StatsCollectorMiddleware) Allocation ¶ added in v0.1.0
func (mw StatsCollectorMiddleware) Allocation() int64
Allocation returns the size allocation in bytes cache
func (StatsCollectorMiddleware) Capacity ¶
func (mw StatsCollectorMiddleware) Capacity() int
Capacity returns the capacity of the cache
func (StatsCollectorMiddleware) Clear ¶
func (mw StatsCollectorMiddleware) Clear(ctx context.Context) error
Clear collects stats for the Clear method.
func (StatsCollectorMiddleware) Count ¶ added in v0.1.0
func (mw StatsCollectorMiddleware) Count() int
Count returns the count of the items in the cache
func (StatsCollectorMiddleware) Get ¶
func (mw StatsCollectorMiddleware) Get(key string) (interface{}, bool)
Get collects stats for the Get method.
func (StatsCollectorMiddleware) GetMultiple ¶
func (mw StatsCollectorMiddleware) GetMultiple(ctx context.Context, keys ...string) (result map[string]any, failed map[string]error)
GetMultiple collects stats for the GetMultiple method.
func (StatsCollectorMiddleware) GetOrSet ¶
func (mw StatsCollectorMiddleware) GetOrSet(ctx context.Context, key string, value any, expiration time.Duration) (any, error)
GetOrSet collects stats for the GetOrSet method.
func (StatsCollectorMiddleware) GetStats ¶
func (mw StatsCollectorMiddleware) GetStats() stats.Stats
GetStats returns the stats of the cache
func (StatsCollectorMiddleware) GetWithInfo ¶ added in v0.1.0
func (mw StatsCollectorMiddleware) GetWithInfo(key string) (*types.Item, bool)
GetWithInfo collects stats for the GetWithInfo method.
func (StatsCollectorMiddleware) List ¶
func (mw StatsCollectorMiddleware) List(ctx context.Context, filters ...backend.IFilter) ([]*types.Item, error)
List collects stats for the List method.
func (StatsCollectorMiddleware) Remove ¶
func (mw StatsCollectorMiddleware) Remove(ctx context.Context, keys ...string)
Remove collects stats for the Remove method.
func (StatsCollectorMiddleware) Set ¶
func (mw StatsCollectorMiddleware) Set(ctx context.Context, key string, value any, expiration time.Duration) error
Set collects stats for the Set method.
func (StatsCollectorMiddleware) Stop ¶
func (mw StatsCollectorMiddleware) Stop()
Stop collects the stats for Stop methods and stops the cache and all its goroutines (if any)
func (StatsCollectorMiddleware) TriggerEviction ¶
func (mw StatsCollectorMiddleware) TriggerEviction()
TriggerEviction triggers the eviction of the cache