cache

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2025 License: Zlib Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(key string, value any) error

Add adds a key/value pair to the cache only if the key doesn't already exist, or if the key has expired. Returns an error otherwise.

func Delete

func Delete(key string)

Delete deletes a key/value pair by key from the cache whether it exists or not.

func Get

func Get(key string) (any, bool)

Get gets a value by key from the cache. It returns the value and a boolean indicating whether the key was found in the cache.

func Set

func Set(key string, value any)

Set sets a key/value pair in the cache. If the key already exists, it will be overwritten.

func SetWithExpiration

func SetWithExpiration(key string, value any, expiration time.Duration)

SetWithExpiration sets a key/value pair in the cache with a given expiration. If the key already exists, it will be overwritten. If expiration is 0, the default expiration time will be used.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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