cache

package
v1.0.3 Latest Latest
Warning

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

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

Documentation

Overview

Package cache implements a cache

Index

Constants

This section is empty.

Variables

View Source
var Cache = cache.New(defaultExpire, defaultPurge)

Cache provides an in-memory key:value store similar to memcached

Functions

func Get

func Get[T any](key string, cb func() (T, error)) (T, error)

Get returns the value for 'key'.

cache hit:

pull the value from the cache and returns it.

cache miss:

call 'cb' function to get a new value. If the callback doesn't return an error the returned value is
cached with no expiration date and returned.

func GetWithExpiration

func GetWithExpiration[T any](key string, cb func() (T, error), expire time.Duration) (T, error)

GetWithExpiration returns the value for 'key'.

cache hit:

pull the value from the cache and returns it.

cache miss:

call 'cb' function to get a new value. If the callback doesn't return an error the returned value is
cached with the given expire duration and returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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