online

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Online

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

Online tracks active users/sessions using a TTL-based cache. It maintains a count of online entities based on configurable key generation.

func NewOnline

func NewOnline() *Online

NewOnline creates a new online tracking instance with an in-memory cache.

func (*Online) Middleware

func (l *Online) Middleware(keygen func(ctx httpx.Context) string, ttl time.Duration) httpx.Middleware

Middleware creates a Gin middleware that tracks online presence. It extracts a key from the request context and updates the online status with the specified TTL.

func (*Online) OnlineCount

func (l *Online) OnlineCount() int

OnlineCount returns the current number of online entities. This count reflects entries that have not yet expired from the cache.

Jump to

Keyboard shortcuts

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