internal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package internal provides internal utility functions and types used across the gencache package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expired

func Expired(t time.Time) bool

Expired returns true if the given time is in the past

Types

type SafeCounter

type SafeCounter struct {
	// contains filtered or unexported fields
}

SafeCounter is a thread-safe counter

func NewSafeCounter

func NewSafeCounter() *SafeCounter

NewSafeCounter creates a new thread-safe counter

func (*SafeCounter) Decrement

func (c *SafeCounter) Decrement()

Decrement decreases the counter by 1

func (*SafeCounter) Get

func (c *SafeCounter) Get() int64

Get returns the current count

func (*SafeCounter) Increment

func (c *SafeCounter) Increment()

Increment increases the counter by 1

func (*SafeCounter) Reset

func (c *SafeCounter) Reset()

Reset sets the counter to 0

type SafeMap

type SafeMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

SafeMap is a thread-safe map

func NewSafeMap

func NewSafeMap[K comparable, V any]() *SafeMap[K, V]

NewSafeMap creates a new thread-safe map

func (*SafeMap[K, V]) Clear

func (m *SafeMap[K, V]) Clear()

Clear removes all values from the map

func (*SafeMap[K, V]) Delete

func (m *SafeMap[K, V]) Delete(key K)

Delete removes a value from the map

func (*SafeMap[K, V]) Get

func (m *SafeMap[K, V]) Get(key K) (V, bool)

Get retrieves a value from the map

func (*SafeMap[K, V]) Set

func (m *SafeMap[K, V]) Set(key K, value V)

Set stores a value in the map

func (*SafeMap[K, V]) Size

func (m *SafeMap[K, V]) Size() int

Size returns the number of items in the map

Jump to

Keyboard shortcuts

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