Documentation ¶
Overview ¶
Package cache provides ready-to-use in-memory cache mechanisms
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶ added in v4.0.1
type Cache interface { Get(key string, value interface{}) (ok bool) GetBytes(key string) (value []byte, ok bool) Set(key string, value interface{}) error SetWithExpiry(key string, value interface{}, duration time.Duration) error Delete(k string) error Reset() error KeysByPrefix(prefix string) ([]string, error) Iterate(it func(key string, val interface{})) error Close() error }
func OpenCache ¶ added in v4.0.1
OpenCache opens a Cache identified by the URL given. See the URLOpener documentation in driver subpackages for details on supported URL formats, and https://gocloud.dev/concepts/urls for more information.
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 Use globalCtx.Done() to stop listening to events
func NewEventsBatcher ¶
func NewEventsBatcher(ctx context.Context, debounce time.Duration, idle time.Duration, max int, atomic bool, process func(context.Context, ...*tree.NodeChangeEvent)) *EventsBatcher
NewEventsBatcher initializes a new EventsBatcher
func (*EventsBatcher) Start ¶
func (b *EventsBatcher) Start()
Start starts listening to incoming events
type InstrumentedCache ¶
type InstrumentedCache struct { Cache // contains filtered or unexported fields }
InstrumentedCache wraps BigCache with metrics
func (*InstrumentedCache) Close ¶
func (i *InstrumentedCache) Close() error
Close stops internal timer for reporting statistics
func (*InstrumentedCache) Delete ¶
func (i *InstrumentedCache) Delete(key string) error
func (*InstrumentedCache) KeysByPrefix ¶
func (i *InstrumentedCache) KeysByPrefix(prefix string) (res []string, e error)
func (*InstrumentedCache) Reset ¶
func (i *InstrumentedCache) Reset() error
func (*InstrumentedCache) Set ¶
func (i *InstrumentedCache) Set(key string, entry interface{}) error
Set adds a key/value to the cache.
type URLMux ¶ added in v4.0.1
type URLMux struct {
// contains filtered or unexported fields
}
URLMux is a URL opener multiplexer. It matches the scheme of the URLs against a set of registered schemes and calls the opener that matches the URL's scheme. See https://gocloud.dev/concepts/urls/ for more information.
The zero value is a multiplexer with no registered schemes.
func DefaultURLMux ¶ added in v4.0.1
func DefaultURLMux() *URLMux
DefaultURLMux returns the URLMux used by OpenTopic and OpenSubscription.
Driver packages can use this to register their TopicURLOpener and/or SubscriptionURLOpener on the mux.
func (*URLMux) OpenCache ¶ added in v4.0.1
OpenCache calls OpenURL with the URL parsed from urlstr. OpenTopic is safe to call from multiple goroutines.
func (*URLMux) Register ¶ added in v4.0.1
Register registers the opener with the given scheme. If an opener already exists for the scheme, Register panics.
func (*URLMux) ValidScheme ¶ added in v4.0.1
ValidScheme returns true if scheme has been registered.