cache

package
v0.6.69 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithPolicyCache

func WithPolicyCache(ctx context.Context, cache *PolicyCache) context.Context

WithPolicyCache returns a new context with the provided PolicyCache added.

Types

type KeyValuePair

type KeyValuePair struct {
	Key   string
	Value string
}

KeyValuePair represents a key-value pair from the cache.

type PolicyCache

type PolicyCache struct {
	Data sync.Map
}

PolicyCache holds cached policy data using a thread-safe map.

func CreatePolicyCache

func CreatePolicyCache() (*PolicyCache, error)

func NewPolicyCache

func NewPolicyCache(ctx context.Context) (*PolicyCache, error)

NewPolicyCache creates and returns a new PolicyCache instance.

func PolicyCacheFromContext

func PolicyCacheFromContext(ctx context.Context) (*PolicyCache, bool)

PolicyCacheFromContext retrieves the PolicyCache from the context. It returns the PolicyCache and true if found, or nil and false otherwise.

func (*PolicyCache) Get

func (c *PolicyCache) Get(key string) (string, bool)

Get retrieves the value and error for the given key from the cache. It returns the value and true if found, or an empty string and false otherwise.

func (*PolicyCache) Set

func (c *PolicyCache) Set(key string, value string, err error)

Set manually sets the value for a given key in the cache. It overwrites any existing value and error.

Jump to

Keyboard shortcuts

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