Documentation
¶
Index ¶
- Variables
- type Cache
- type Clock
- type Config
- type Decoder
- type DummyMetrics
- func (DummyMetrics) Del(_ string)
- func (DummyMetrics) Dump(_ string)
- func (DummyMetrics) Evict(_ string)
- func (DummyMetrics) Expire(_ string)
- func (DummyMetrics) Hit(_ string, _ time.Duration)
- func (DummyMetrics) Load(_ string)
- func (DummyMetrics) Miss(_ string)
- func (DummyMetrics) Overflow(_ string)
- func (DummyMetrics) Set(_ string, _ time.Duration)
- type DumpReader
- type DumpWriter
- type Encoder
- type Entry
- type Hasher
- type Logger
- type MarshallerTo
- type MetricsWriter
- type NativeClock
- type Unmarshaller
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrOK error = nil ErrNoConfig = errors.New("no config provided") ErrBadCache = errors.New("cache uninitialized, use New()") ErrCacheClosed = errors.New("cache closed") ErrNoHasher = errors.New("no hasher provided") ErrNoBuckets = errors.New("buckets must be greater than zero") ErrShortTTL = errors.New("TTL must be greater than one second") ErrNotFound = errors.New("entry not found") ErrExpire = errors.New("entry expired") )
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock interface {
// Start the clock.
Start()
// Stop the clock.
Stop()
// Active checks if clock is started.
Active() bool
// Now returns current time considering jumps.
Now() time.Time
// Jump performs time travel to delta (maybe negative). Now and scheduled jobs considers jumps.
Jump(delta time.Duration)
// Schedule registers fn to call at every d.
Schedule(d time.Duration, fn func())
}
Clock describes timer helper with testing features (like Jump).
type Config ¶
type Config[T any] struct { Size uint64 Buckets uint Hasher Hasher TTLInterval time.Duration EvictInterval time.Duration EvictWorkers uint DumpWriter DumpWriter DumpEncoder Encoder[T] DumpInterval time.Duration DumpWriteWorkers uint DumpReader DumpReader DumpDecoder Decoder[T] DumpReadBuffer uint DumpReadWorkers uint DumpReadAsync bool MetricsWriter MetricsWriter Clock Clock Logger Logger }
type DummyMetrics ¶
type DummyMetrics struct{}
func (DummyMetrics) Del ¶
func (DummyMetrics) Del(_ string)
func (DummyMetrics) Dump ¶
func (DummyMetrics) Dump(_ string)
func (DummyMetrics) Evict ¶
func (DummyMetrics) Evict(_ string)
func (DummyMetrics) Expire ¶
func (DummyMetrics) Expire(_ string)
func (DummyMetrics) Load ¶
func (DummyMetrics) Load(_ string)
func (DummyMetrics) Miss ¶
func (DummyMetrics) Miss(_ string)
func (DummyMetrics) Overflow ¶
func (DummyMetrics) Overflow(_ string)
type DumpReader ¶
type Logger ¶
type Logger interface {
Printf(format string, v ...interface{})
Print(v ...interface{})
Println(v ...interface{})
}
type MetricsWriter ¶
type NativeClock ¶
type NativeClock struct {
// contains filtered or unexported fields
}
NativeClock is a primitive clock based on time package.
Jump doesn't work in that implementation.
func (*NativeClock) Active ¶
func (n *NativeClock) Active() bool
func (*NativeClock) Jump ¶
func (n *NativeClock) Jump(_ time.Duration)
func (*NativeClock) Now ¶
func (n *NativeClock) Now() time.Time
func (*NativeClock) Schedule ¶
func (n *NativeClock) Schedule(d time.Duration, fn func())
func (*NativeClock) Start ¶
func (n *NativeClock) Start()
func (*NativeClock) Stop ¶
func (n *NativeClock) Stop()
type Unmarshaller ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.