cache

package
v2.2.11+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2021 License: AGPL-3.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cache provides ready-to-use in-memory cache mechanisms

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultBigCacheConfig

func DefaultBigCacheConfig() bigcache.Config

Types

type EventWithContext

type EventWithContext struct {
	tree.NodeChangeEvent
	Ctx context.Context
}

EventWithContext composes a NodeChangeEvent and a context

type EventsBatcher

type EventsBatcher struct {
	Events chan *EventWithContext
	Done   chan bool
	// contains filtered or unexported fields
}

EventsBatcher debounces events on a given timeframe and calls process on them afterward

func NewEventsBatcher

func NewEventsBatcher(ctx context.Context, debounce time.Duration, idle time.Duration, max int, process func(context.Context, *tree.NodeChangeEvent)) *EventsBatcher

NewEventsBatcher inits a new EventsBatcher

func (*EventsBatcher) Start

func (b *EventsBatcher) Start()

Start starts listening to incoming events

func (*EventsBatcher) Stop

func (b *EventsBatcher) Stop()

Stop stops listening to incoming events

type InstrumentedCache

type InstrumentedCache struct {
	bigcache.BigCache
	// contains filtered or unexported fields
}

InstrumentCache wraps BigCache with metrics

func NewInstrumentedCache

func NewInstrumentedCache(serviceName string, cacheConfig ...bigcache.Config) *InstrumentedCache

NewInstrumentedCache creates a BigCache instance with a regular report of statistics

func (*InstrumentedCache) Close

func (i *InstrumentedCache) Close()

Close stops internal timer for reporting statistics

func (*InstrumentedCache) Set

func (i *InstrumentedCache) Set(key string, entry []byte) error

Set adds a key/value to the cache.

type KeyMutex

type KeyMutex struct {
	// contains filtered or unexported fields
}

KeyMutex allows locking resource by a unique ID instead of using a global lock

func NewKeyMutex

func NewKeyMutex() *KeyMutex

NewKeyMutex creates a new KeyMutex.

func (*KeyMutex) Lock

func (km *KeyMutex) Lock(key string)

Lock locks the KeyMutex by unique ID.

func (*KeyMutex) Unlock

func (km *KeyMutex) Unlock(key string)

Unlock unlocks the KeyMutex by unique ID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL