cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Cache is a simple cache, which is used to store whether functions have been invoked yet. This reduces the amount of API calls and cost in the metrics functions. The cache gets deleted as soon as the process is killed.

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
}

The actual cache implementation, thread safety is guaranteed via a mutex. The cache stores the String() of a CacheKey and the amount of invocations.

func NewCache

func NewCache() *Cache

func (*Cache) Get

func (c *Cache) Get(key CacheKey) (int, bool)

Get returns the invocation count for the key and a bool indicating if it was found.

func (*Cache) Has

func (c *Cache) Has(key CacheKey) bool

Has returns true if the key exists in the cache.

func (*Cache) Set

func (c *Cache) Set(key CacheKey, count int)

Set stores the invocation count for the given key.

type CacheKey

type CacheKey struct {
	FunctionName string
	Qualifier    string
	Start        time.Time
	End          time.Time
}

CacheKey contains the identifiers of a lambda function and invocation interval. It is not stored in the types package as CacheKey is not meant to be used by users.

func (CacheKey) String

func (k CacheKey) String() string

This computes a string out of CacheKey

Jump to

Keyboard shortcuts

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