cache

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Defaults = CacheDefaults{
	MaxRetries:          3,
	Timeout:             10 * time.Second,
	TTL:                 10 * time.Minute,
	MaxLocalSize:        100,
	MaxItemSize:         512 * 1024,
	DynamoDBMaxItemSize: 400 * 1024,
	S3MaxObjectSize:     1024 * 1024,
}

Defaults provides the default configuration values for all cache implementations

Functions

func GetConfiguredMaxLocalSize

func GetConfiguredMaxLocalSize(cfg *config.Config) int

GetConfiguredMaxLocalSize returns the max local size from config or the default if not specified

func GetConfiguredTTL

func GetConfiguredTTL(cfg *config.Config) time.Duration

GetConfiguredTTL returns the TTL from config or the default if not specified

Types

type Cache

type Cache interface {
	Get(key string) (*types.JWKS, bool)
	Set(key string, value *types.JWKS, ttl time.Duration)
}

Cache interface defines the methods that all cache implementations must provide

func NewCache

func NewCache(cfg *config.Config) (Cache, error)

NewCache creates a new cache implementation based on the configuration

func NewDynamoDBCache

func NewDynamoDBCache(tableName string, opts ...DynamoDBCacheOption) (Cache, error)

NewDynamoDBCache creates a new DynamoDB cache with the given table name

func NewMemoryCache

func NewMemoryCache() Cache

func NewS3Cache

func NewS3Cache(bucketName, prefix string, opts ...S3CacheOption) (Cache, error)

NewS3Cache creates a new S3 cache with the given client and bucket

type CacheDefaults

type CacheDefaults struct {
	// General defaults
	MaxRetries   int
	Timeout      time.Duration
	TTL          time.Duration
	MaxLocalSize int

	// Size limits
	MaxItemSize int64 // Maximum size of a cache item

	// Cache-specific defaults
	DynamoDBMaxItemSize int64
	S3MaxObjectSize     int64
}

CacheDefaults holds all default configuration values for cache implementations These constants are centralized here to ensure consistency across different cache types

type DynamoDBCacheOption

type DynamoDBCacheOption func(*dynamoDBCacheOptions)

DynamoDBCacheOption is a function that configures the DynamoDB cache

func WithDynamoDBAWSConfig

func WithDynamoDBAWSConfig(cfg aws.Config) DynamoDBCacheOption

WithDynamoDBAWSConfig sets a custom AWS configuration

func WithDynamoDBDefaultTTL

func WithDynamoDBDefaultTTL(ttl time.Duration) DynamoDBCacheOption

WithDynamoDBDefaultTTL sets the default TTL for cache items

func WithDynamoDBMaxLocalSize

func WithDynamoDBMaxLocalSize(size int) DynamoDBCacheOption

WithDynamoDBMaxLocalSize sets the maximum size of the local memory cache

type S3CacheOption

type S3CacheOption func(*s3CacheOptions)

S3CacheOption is a function that configures the S3 cache

func WithAWSConfig

func WithAWSConfig(cfg aws.Config) S3CacheOption

WithAWSConfig sets a custom AWS configuration

func WithDefaultTTL

func WithDefaultTTL(ttl time.Duration) S3CacheOption

WithDefaultTTL sets the default TTL for cache items

func WithMaxLocalSize

func WithMaxLocalSize(size int) S3CacheOption

WithMaxLocalSize sets the maximum size of the local memory cache

Jump to

Keyboard shortcuts

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