Documentation
¶
Overview ¶
Package models defines the data structures used throughout memtui.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidMetadumpLine = errors.New("invalid metadump line")
ErrInvalidMetadumpLine is returned when a metadump line cannot be parsed
Functions ¶
func FormatBytes ¶
FormatBytes formats bytes in human-readable units.
Types ¶
type Item ¶
type Item struct {
Key string
Value []byte
Flags uint32
CAS uint64
// TTL-related fields (from metadump)
Expiration int64 // Unix timestamp (0 = permanent)
LastAccess int64 // Last access time
// Computed fields
TTLRemaining int64 // Remaining TTL in seconds (calculated in real-time)
IsExpired bool // Expiration flag
}
Item represents an item stored in Memcached.
type KeyInfo ¶
type KeyInfo struct {
Key string // Key name
Expiration int64 // Unix timestamp (0 = permanent)
LastAccess int64 // Last access timestamp
CAS uint64 // CAS value
Fetch bool // Whether fetch has been performed
SlabClass int // Slab class ID
Size int // Size in bytes
}
KeyInfo represents metadata for a Memcached key from lru_crawler metadump
func FilterKeyInfos ¶
FilterKeyInfos returns keys that contain the given pattern
func ParseMetadumpLine ¶
ParseMetadumpLine parses a single line from lru_crawler metadump output Format: key=<key> exp=<exp> la=<la> cas=<cas> fetch=<yes|no> cls=<cls> size=<size>
func SortKeyInfos ¶
SortKeyInfos returns a sorted copy of the KeyInfo slice
func (KeyInfo) IsExpiredAt ¶
IsExpiredAt checks if the key is expired at the given timestamp Returns false for permanent keys (Expiration == 0)
type SlabItemStats ¶
type SlabItemStats struct {
SlabID int // Slab class ID
Number int64 // Number of items in this slab class
Age int64 // Age of oldest item in seconds
Evicted int64 // Items evicted from this slab class
EvictedNZ int64 // Items evicted with non-zero TTL
Outofmem int64 // Times memory allocation failed
}
SlabItemStats represents stats for items in a slab class (from 'stats items').
type SlabStats ¶
type SlabStats struct {
SlabID int // Slab class ID
ChunkSize int64 // Bytes per chunk
Chunks int64 // Total chunks in this slab class
UsedChunks int64 // Chunks currently in use
FreeChunks int64 // Chunks not in use
MemReq int64 // Memory requested for this slab class
}
SlabStats represents stats for a slab class (from 'stats slabs').
type SlabsStats ¶
type SlabsStats struct {
ActiveSlabs int // Number of active slab classes
TotalMalloced int64 // Total memory allocated for slabs
Slabs map[int]*SlabStats // Per-slab statistics
}
SlabsStats represents overall slab statistics.
type Stats ¶
type Stats struct {
// Process info
PID int // Process ID
Uptime int64 // Seconds since server start
// Version
Version string // Memcached version string
// Connections
CurrentConnections int // Current open connections
TotalConnections int64 // Total connections since start
// Items
CurrentItems int64 // Current number of items stored
TotalItems int64 // Total items stored since start
// Memory
Bytes int64 // Current bytes used for storage
LimitMaxBytes int64 // Maximum bytes allowed (limit_maxbytes)
// Cache performance
GetHits int64 // Cache hits
GetMisses int64 // Cache misses
Evictions int64 // Items evicted to free memory
HitRate float64 // Calculated hit rate percentage
// Network I/O
BytesRead int64 // Total bytes read from network
BytesWritten int64 // Total bytes written to network
// Raw contains all STAT key-value pairs
Raw map[string]string
}
Stats represents Memcached server statistics from the 'stats' command.
func ParseStatsResponse ¶
ParseStatsResponse parses the response from a Memcached 'stats' command. The response format is:
STAT <key> <value>\r\n ... END\r\n
func (*Stats) BytesFormatted ¶
BytesFormatted returns the bytes used in a human-readable format.
func (*Stats) MemoryUsagePercent ¶
MemoryUsagePercent returns the percentage of memory used.
func (*Stats) UptimeFormatted ¶
UptimeFormatted returns the uptime in a human-readable format.