cache

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2025 License: AGPL-3.0 Imports: 2 Imported by: 0

README

cache

import "github.com/agentstation/starmap/internal/server/cache"

Package cache provides an in-memory caching layer for the HTTP server. It uses patrickmn/go-cache for TTL-based caching with LRU-like eviction.

Index

type Cache

Cache wraps go-cache with additional features for HTTP caching.

type Cache struct {
    // contains filtered or unexported fields
}

func New
func New(defaultTTL, cleanupInterval time.Duration) *Cache

New creates a new cache with the given TTL and cleanup interval. defaultTTL is the default expiration time for cache entries. cleanupInterval is how often expired items are removed from memory.

func (*Cache) Clear
func (c *Cache) Clear()

Clear removes all items from the cache.

func (*Cache) Delete
func (c *Cache) Delete(key string)

Delete removes a value from the cache.

func (*Cache) Get
func (c *Cache) Get(key string) (any, bool)

Get retrieves a value from the cache.

func (*Cache) GetStats
func (c *Cache) GetStats() Stats

GetStats returns current cache statistics.

func (*Cache) ItemCount
func (c *Cache) ItemCount() int

ItemCount returns the number of items in the cache.

func (*Cache) Set
func (c *Cache) Set(key string, value any)

Set stores a value in the cache with default TTL.

func (*Cache) SetWithTTL
func (c *Cache) SetWithTTL(key string, value any, ttl time.Duration)

SetWithTTL stores a value in the cache with custom TTL.

type Stats

Stats returns cache statistics.

type Stats struct {
    ItemCount int `json:"item_count"`
}

Generated by gomarkdoc

Documentation

Overview

Package cache provides an in-memory caching layer for the HTTP server. It uses patrickmn/go-cache for TTL-based caching with LRU-like eviction.

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 wraps go-cache with additional features for HTTP caching.

func New

func New(defaultTTL, cleanupInterval time.Duration) *Cache

New creates a new cache with the given TTL and cleanup interval. defaultTTL is the default expiration time for cache entries. cleanupInterval is how often expired items are removed from memory.

func (*Cache) Clear

func (c *Cache) Clear()

Clear removes all items from the cache.

func (*Cache) Delete

func (c *Cache) Delete(key string)

Delete removes a value from the cache.

func (*Cache) Get

func (c *Cache) Get(key string) (any, bool)

Get retrieves a value from the cache.

func (*Cache) GetStats

func (c *Cache) GetStats() Stats

GetStats returns current cache statistics.

func (*Cache) ItemCount

func (c *Cache) ItemCount() int

ItemCount returns the number of items in the cache.

func (*Cache) Set

func (c *Cache) Set(key string, value any)

Set stores a value in the cache with default TTL.

func (*Cache) SetWithTTL

func (c *Cache) SetWithTTL(key string, value any, ttl time.Duration)

SetWithTTL stores a value in the cache with custom TTL.

type Stats

type Stats struct {
	ItemCount int `json:"item_count"`
}

Stats returns cache statistics.

Jump to

Keyboard shortcuts

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