Documentation
¶
Overview ¶
Package util provides utility functions for type conversions and other common operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SafeIntToUint16 ¶
SafeIntToUint16 converts int to uint16 with overflow check.
func SafeIntToUint32 ¶
SafeIntToUint32 converts int to uint32 with overflow check.
func SafeIntToUint8 ¶
SafeIntToUint8 converts int to uint8 with overflow check.
func SafeUintToInt ¶
SafeUintToInt converts uint to int with overflow check.
Types ¶
type TTLCache ¶ added in v0.10.1
type TTLCache[V any] struct { // contains filtered or unexported fields }
TTLCache is a simple in-memory cache with time-to-live expiration. Expired entries are removed lazily during Get and Set operations.
func NewTTLCache ¶ added in v0.10.1
NewTTLCache creates a cache with the specified TTL for all entries.
func (*TTLCache[V]) Clear ¶ added in v0.10.1
func (c *TTLCache[V]) Clear()
Clear removes all entries from the cache.
func (*TTLCache[V]) Get ¶ added in v0.10.1
Get retrieves a value if it exists and hasn't expired. Returns the value and true if found and valid, zero value and false otherwise.