caching

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Index

Constants

View Source
const (
	// TODO: Verify where these values come from?
	FixedProcessingOverheadMs = 10
	FixedStorageOverheadBytes = 100
	MaxEntryCount             = 10000
	MaxAggregatePayloadBytes  = 10000000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func New

func New(clock Clock, ttl time.Duration, requestTopic string) *Cache

New creates a new cache.

func (*Cache) Exec added in v0.1.1

func (c *Cache) Exec(req *mqtt.Message, cb Callback) (*mqtt.Message, error)

Exec will return the cached response message, executing the provided function to produce it if necessary. A nil message with no error indicates that the request should be dropped, e.g. if it has expired or a duplicate request is already in-flight.

type Callback added in v0.1.1

type Callback = func() (*mqtt.Message, error)

type Clock added in v0.1.1

type Clock interface {
	Now() time.Time
}

Clock used for test dependency injection.

Jump to

Keyboard shortcuts

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