caching

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

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) *Cache

New creates a new cache.

func (*Cache) Exec added in v0.1.1

func (c *Cache) Exec(
	req *mqtt.Message,
	cb func() (*mqtt.Message, error),
) (*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 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