checkcache

package
v0.0.0-...-5c99f88 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package checkcache provides a scalable cache to hold results of Mixer.Check operations.

Entries are added into the cache by supplying an attribute bag along with a ReferencedAttributes struct which determines the set of attributes in the bag should be used as a cache lookup key. Entries are looked up from the cache using an attribute bag.

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
}

Cache holds cached results of calls to Mixer.Check

func New

func New(capacity int32) *Cache

New creates a new instance of a check cache with the given maximum capacity. Adding more items to the cache then its capacity will cause eviction of older entries.

func (*Cache) Close

func (cc *Cache) Close() error

Close releases any resources used by the check cache.

func (*Cache) Get

func (cc *Cache) Get(attrs attribute.Bag) (Value, bool)

Get looks up an attribute bag in the cache.

func (*Cache) Set

func (cc *Cache) Set(attrs attribute.Bag, value Value)

Set enters a new value in the cache.

type Value

type Value struct {
	// StatusCode for the Check operation
	StatusCode int32

	// StatusMessage for the Check operation
	StatusMessage string

	// Expiration is the point at which this cache value becomes stale and shouldn't be used
	Expiration time.Time

	// ValidUseCount for the Check operation
	ValidUseCount int32

	// ReferencedAttributes for the Check operation
	ReferencedAttributes mixerpb.ReferencedAttributes

	// RouteDirective for the completed Check operation
	RouteDirective *mixerpb.RouteDirective
}

Value holds the data that the check cache stores.

Jump to

Keyboard shortcuts

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