common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JoinBytes

func JoinBytes(bytes ...interface{}) []byte

JoinBytes is an easy way to join multiple values into a single []byte

func SysFreeMemory

func SysFreeMemory() float64

SysFreeMemory returns the amount of memory available in megabytes

Types

type CacheMap

type CacheMap[T any] struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache[T any]() CacheMap[T]

func (*CacheMap[T]) DelOld

func (cache *CacheMap[T]) DelOld(cacheTime time.Duration)

delOld removes old cache items

func (*CacheMap[T]) Get

func (cache *CacheMap[T]) Get(key string) (T, error)

get returns a value or an error if it exists

if the object key does not exist, it will return both a nil/zero value (of the relevant type) and nil error

func (*CacheMap[T]) Set

func (cache *CacheMap[T]) Set(key string, value T, err error)

set sets or adds a new key with either a value, or an error

Jump to

Keyboard shortcuts

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