package cacheqm

import "github.com/google/trillian/quota/cacheqm"

Package cacheqm contains a caching quota.Manager implementation.

Index

Constants

const (
	// DefaultMinBatchSize is the suggested default for minBatchSize.
	DefaultMinBatchSize = 100

	// DefaultMaxCacheEntries is the suggested default for maxEntries.
	DefaultMaxCacheEntries = 1000
)

Functions

func NewCachedManager

func NewCachedManager(qm quota.Manager, minBatchSize, maxEntries int) (quota.Manager, error)

NewCachedManager wraps a quota.Manager with an implementation that caches tokens locally.

minBatchSize determines the minimum number of tokens requested from qm for each GetTokens() request.

maxEntries determines the maximum number of cache entries, apart from global quotas. The oldest entries are evicted as necessary, their tokens replenished via PutTokens() to avoid excessive leakage.

Source Files

cache.go

Version
v1.7.1 (latest)
Published
Jan 9, 2025
Platform
linux/amd64
Imports
7 packages
Last checked
5 days ago

Tools for package owners.