cache

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(model CacheModel)

Init sets the package-level CacheModel used by @call Func wrappers.

Types

type CacheModel

type CacheModel interface {
	Set(ctx context.Context, key string, value any, ttl time.Duration) error
	Get(ctx context.Context, key string) (string, error)
	Delete(ctx context.Context, key string) error
}

CacheModel provides key-value + TTL storage for data efficiency (caching).

func NewMemoryCache

func NewMemoryCache() CacheModel

NewMemoryCache creates an in-memory CacheModel. Data is lost on restart.

func NewPostgresCache

func NewPostgresCache(ctx context.Context, db *sql.DB) (CacheModel, error)

NewPostgresCache creates a CacheModel backed by PostgreSQL. It auto-creates the fullend_cache table if not exists.

type DeleteRequest

type DeleteRequest struct {
	Key string
}

type DeleteResponse

type DeleteResponse struct{}

func Delete

func Delete(req DeleteRequest) (DeleteResponse, error)

type GetRequest

type GetRequest struct {
	Key string
}

type GetResponse

type GetResponse struct {
	Value string
}

func Get

func Get(req GetRequest) (GetResponse, error)

type SetRequest

type SetRequest struct {
	Key   string
	Value string
	TTL   int64
}

type SetResponse

type SetResponse struct{}

func Set

func Set(req SetRequest) (SetResponse, error)

Jump to

Keyboard shortcuts

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