cache

package
v0.0.0-...-b50b3a4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package cache provides a comprehensive Redis-based caching system for PlantUML diagrams and UML state machine definitions with enterprise-grade reliability features.

This package implements a hierarchical caching layer that supports:

  • PlantUML diagram storage and retrieval with configurable TTL
  • Parsed UML state machine caching with version management
  • Individual state machine entity caching with referential integrity
  • Comprehensive error handling with typed errors and recovery strategies
  • Configurable retry logic with exponential backoff and circuit breakers
  • Health monitoring, diagnostics, and performance metrics
  • Thread-safe concurrent access with connection pooling
  • Security-focused input validation and sanitization

Key Structure

The cache uses a hierarchical key structure in Redis:

  • PlantUML Diagrams: /diagrams/<diagram_type>/<diagram_name>
  • Parsed State Machines: /machines/<uml_version>/<diagram_name>
  • State Machine Entities: /machines/<uml_version>/<diagram_name>/entities/<entity_id>

Basic Usage

config := cache.DefaultRedisConfig()
config.RedisAddr = "localhost:6379"

redisCache, err := cache.NewRedisCache(config)
if err != nil {
    log.Fatal(err)
}
defer redisCache.Close()

ctx := context.Background()

// Store and retrieve PUML diagrams
err = redisCache.StoreDiagram(ctx, models.DiagramTypePUML, "my-diagram", pumlContent, time.Hour)
content, err := redisCache.GetDiagram(ctx, models.DiagramTypePUML, "my-diagram")

Error Handling

The package provides comprehensive error handling with typed errors:

_, err := redisCache.GetDiagram(ctx, models.DiagramTypePUML, "nonexistent")
if err != nil {
    switch {
    case cache.IsNotFoundError(err):
        // Handle cache miss
    case cache.IsConnectionError(err):
        // Handle Redis connection issues
    case cache.IsValidationError(err):
        // Handle input validation errors
    }
}

Health Monitoring

// Basic health check
err = redisCache.Health(ctx)

// Detailed health status
health, err := redisCache.HealthDetailed(ctx)
fmt.Printf("Status: %s, Response Time: %v\n", health.Status, health.ResponseTime)

API Separation

This package provides the public API for the cache system. Internal implementation details are in the internal package and should not be used directly by applications.

Public API (this package):

  • Cache interface and RedisCache implementation
  • Configuration types (RedisConfig, RedisRetryConfig)
  • Error types and utility functions
  • Health monitoring and cleanup types

Internal API (internal package):

  • Low-level Redis client wrapper
  • Key generation and validation
  • Input validation and sanitization
  • Error recovery and circuit breaker implementation

Thread Safety

All operations are thread-safe and support concurrent access from multiple goroutines. The library handles internal synchronization and connection pooling automatically.

Performance

The library is optimized for high-performance scenarios with:

  • Connection pooling for efficient Redis connections
  • Batch operations for bulk deletions
  • Configurable timeouts and retry policies
  • Memory usage monitoring and optimization

Security

The library includes comprehensive security measures:

  • Input validation and sanitization for all parameters
  • SQL injection and XSS pattern detection
  • Path traversal prevention
  • Safe key generation with proper encoding

For complete documentation, examples, and configuration guides, see:

  • README.md - Comprehensive usage guide
  • API.md - Complete API reference
  • CONFIGURATION.md - Configuration and tuning guide
  • examples/ directory - Working code examples

Index

Constants

View Source
const (
	ErrorTypeConnection     = internal.ErrorTypeConnection
	ErrorTypeKeyInvalid     = internal.ErrorTypeKeyInvalid
	ErrorTypeNotFound       = internal.ErrorTypeNotFound
	ErrorTypeSerialization  = internal.ErrorTypeSerialization
	ErrorTypeTimeout        = internal.ErrorTypeTimeout
	ErrorTypeCapacity       = internal.ErrorTypeCapacity
	ErrorTypeValidation     = internal.ErrorTypeValidation
	ErrorTypeRetryExhausted = internal.ErrorTypeRetryExhausted
	ErrorTypeCircuitOpen    = internal.ErrorTypeCircuitOpen
)

Error type constants

View Source
const (
	SeverityLow      = internal.SeverityLow
	SeverityMedium   = internal.SeverityMedium
	SeverityHigh     = internal.SeverityHigh
	SeverityCritical = internal.SeverityCritical
)

Error severity constants

Variables

This section is empty.

Functions

func IsCircuitOpenError

func IsCircuitOpenError(err error) bool

IsCircuitOpenError checks if the error is a circuit open error

func IsConnectionError

func IsConnectionError(err error) bool

IsConnectionError checks if the error is a connection error

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError checks if the error is a not found error

func IsRetryExhaustedError

func IsRetryExhaustedError(err error) bool

IsRetryExhaustedError checks if the error is a retry exhausted error

func IsRetryableError

func IsRetryableError(err error) bool

IsRetryableError checks if the error should trigger retry logic

func IsValidationError

func IsValidationError(err error) bool

IsValidationError checks if the error is a validation error

Types

type Cache

type Cache interface {
	// Diagram operations
	StoreDiagram(ctx context.Context, diagramType models.DiagramType, name string, diagContent string, ttl time.Duration) error
	GetDiagram(ctx context.Context, diagramType models.DiagramType, name string) (string, error)
	DeleteDiagram(ctx context.Context, diagramType models.DiagramType, name string) error

	// State machine operations
	StoreStateMachine(ctx context.Context, umlVersion string, diagramType models.DiagramType, name string, machine *models.StateMachine, ttl time.Duration) error
	GetStateMachine(ctx context.Context, umlVersion, name string) (*models.StateMachine, error)
	DeleteStateMachine(ctx context.Context, umlVersion, name string) error

	// Entity operations
	StoreEntity(ctx context.Context, umlVersion, diagramName, entityID string, entity interface{}, ttl time.Duration) error
	GetEntity(ctx context.Context, umlVersion, diagramName, entityID string) (interface{}, error)
	UpdateStateMachineEntityMapping(ctx context.Context, umlVersion, name string, entityID, entityKey string, operation string) error

	// Type-safe entity retrieval methods
	GetEntityAsState(ctx context.Context, umlVersion, diagramName, entityID string) (*models.State, error)
	GetEntityAsTransition(ctx context.Context, umlVersion, diagramName, entityID string) (*models.Transition, error)
	GetEntityAsRegion(ctx context.Context, umlVersion, diagramName, entityID string) (*models.Region, error)
	GetEntityAsVertex(ctx context.Context, umlVersion, diagramName, entityID string) (*models.Vertex, error)

	// Management operations
	Cleanup(ctx context.Context, pattern string) error
	Health(ctx context.Context) error
	Close() error

	// Enhanced cleanup and monitoring operations
	CleanupWithOptions(ctx context.Context, pattern string, options *CleanupOptions) (*CleanupResult, error)
	GetCacheSize(ctx context.Context) (*CacheSizeInfo, error)

	// Enhanced health monitoring operations
	HealthDetailed(ctx context.Context) (*HealthStatus, error)
	GetConnectionHealth(ctx context.Context) (*ConnectionHealth, error)
	GetPerformanceMetrics(ctx context.Context) (*PerformanceMetrics, error)
	RunDiagnostics(ctx context.Context) (*DiagnosticInfo, error)
}

Cache defines the interface for caching PlantUML diagrams and parsed state machines

type CacheSizeInfo

type CacheSizeInfo struct {
	TotalKeys         int64 `json:"total_keys"`
	DiagramCount      int64 `json:"diagram_count"`
	StateMachineCount int64 `json:"state_machine_count"`
	EntityCount       int64 `json:"entity_count"`
	MemoryUsed        int64 `json:"memory_used"`     // Bytes
	MemoryPeak        int64 `json:"memory_peak"`     // Bytes
	MemoryOverhead    int64 `json:"memory_overhead"` // Bytes
}

CacheSizeInfo contains information about cache size and usage

type CleanupOptions

type CleanupOptions struct {
	BatchSize      int           `json:"batch_size"`      // Number of keys to delete per batch
	ScanCount      int64         `json:"scan_count"`      // Number of keys to scan per SCAN operation
	MaxKeys        int64         `json:"max_keys"`        // Maximum number of keys to delete (0 = no limit)
	DryRun         bool          `json:"dry_run"`         // If true, only scan but don't delete
	Timeout        time.Duration `json:"timeout"`         // Timeout for the entire cleanup operation
	CollectMetrics bool          `json:"collect_metrics"` // Whether to collect detailed metrics
}

CleanupOptions configures cleanup behavior

func DefaultCleanupOptions

func DefaultCleanupOptions() *CleanupOptions

DefaultCleanupOptions returns sensible default cleanup options

type CleanupResult

type CleanupResult struct {
	KeysScanned    int64         `json:"keys_scanned"`
	KeysDeleted    int64         `json:"keys_deleted"`
	BytesFreed     int64         `json:"bytes_freed"`
	Duration       time.Duration `json:"duration"`
	BatchesUsed    int           `json:"batches_used"`
	ErrorsOccurred int           `json:"errors_occurred"`
}

CleanupResult contains information about a cleanup operation

type ConfigCheck

type ConfigCheck struct {
	Valid           bool     `json:"valid"`                     // Whether configuration is valid
	Issues          []string `json:"issues,omitempty"`          // Configuration issues found
	Recommendations []string `json:"recommendations,omitempty"` // Configuration recommendations
}

ConfigCheck contains configuration validation results

type ConnectionHealth

type ConnectionHealth struct {
	Connected   bool                `json:"connected"`            // Whether Redis is connected
	Address     string              `json:"address"`              // Redis server address
	Database    int                 `json:"database"`             // Redis database number
	PingLatency time.Duration       `json:"ping_latency"`         // Latency of ping command
	PoolStats   ConnectionPoolStats `json:"pool_stats"`           // Connection pool statistics
	LastError   string              `json:"last_error,omitempty"` // Last connection error if any
}

ConnectionHealth contains connection-specific health information

type ConnectionPoolStats

type ConnectionPoolStats struct {
	TotalConnections  int `json:"total_connections"`  // Total connections in pool
	IdleConnections   int `json:"idle_connections"`   // Idle connections
	ActiveConnections int `json:"active_connections"` // Active connections
	Hits              int `json:"hits"`               // Pool hits
	Misses            int `json:"misses"`             // Pool misses
	Timeouts          int `json:"timeouts"`           // Pool timeouts
	StaleConnections  int `json:"stale_connections"`  // Stale connections
}

ConnectionPoolStats contains Redis connection pool statistics

type DataIntegrityCheck

type DataIntegrityCheck struct {
	Consistent   bool     `json:"consistent"`       // Whether data is consistent
	Issues       []string `json:"issues,omitempty"` // Data integrity issues found
	OrphanedKeys int64    `json:"orphaned_keys"`    // Number of orphaned keys found
}

DataIntegrityCheck contains data integrity validation results

type DiagnosticInfo

type DiagnosticInfo struct {
	ConfigurationCheck ConfigCheck        `json:"configuration"`             // Configuration validation
	NetworkCheck       NetworkCheck       `json:"network"`                   // Network connectivity check
	PerformanceCheck   PerformanceCheck   `json:"performance"`               // Performance validation
	DataIntegrityCheck DataIntegrityCheck `json:"data_integrity"`            // Data integrity validation
	Recommendations    []string           `json:"recommendations,omitempty"` // Performance recommendations
}

DiagnosticInfo contains diagnostic information for troubleshooting

type Error

type Error = internal.CacheError

Error represents a cache-specific error with detailed context

type ErrorContext

type ErrorContext = internal.ErrorContext

ErrorContext provides additional context information for errors

type ErrorSeverity

type ErrorSeverity = internal.ErrorSeverity

ErrorSeverity represents the severity level of an error

func GetErrorSeverity

func GetErrorSeverity(err error) ErrorSeverity

GetErrorSeverity returns the severity level of an error

type ErrorType

type ErrorType = internal.ErrorType

ErrorType represents the type of cache error

type HealthStatus

type HealthStatus struct {
	Status       string             `json:"status"`             // "healthy", "degraded", "unhealthy"
	Timestamp    time.Time          `json:"timestamp"`          // When the health check was performed
	ResponseTime time.Duration      `json:"response_time"`      // Time taken for health check
	Connection   ConnectionHealth   `json:"connection"`         // Connection-specific health info
	Performance  PerformanceMetrics `json:"performance"`        // Performance metrics
	Diagnostics  DiagnosticInfo     `json:"diagnostics"`        // Diagnostic information
	Errors       []string           `json:"errors,omitempty"`   // Any errors encountered
	Warnings     []string           `json:"warnings,omitempty"` // Any warnings
}

HealthStatus represents the overall health status of the cache system

type KeyspaceMetrics

type KeyspaceMetrics struct {
	TotalKeys      int64   `json:"total_keys"`       // Total number of keys
	ExpiringKeys   int64   `json:"expiring_keys"`    // Keys with expiration
	AverageKeySize float64 `json:"average_key_size"` // Average key size in bytes
	KeyspaceHits   int64   `json:"keyspace_hits"`    // Keyspace hits
	KeyspaceMisses int64   `json:"keyspace_misses"`  // Keyspace misses
	HitRate        float64 `json:"hit_rate"`         // Cache hit rate percentage
}

KeyspaceMetrics contains keyspace statistics

type MemoryMetrics

type MemoryMetrics struct {
	UsedMemory          int64   `json:"used_memory"`          // Used memory in bytes
	UsedMemoryHuman     string  `json:"used_memory_human"`    // Human readable used memory
	UsedMemoryPeak      int64   `json:"used_memory_peak"`     // Peak memory usage
	MemoryFragmentation float64 `json:"memory_fragmentation"` // Memory fragmentation ratio
	MaxMemory           int64   `json:"max_memory"`           // Maximum memory limit
	MaxMemoryPolicy     string  `json:"max_memory_policy"`    // Memory eviction policy
}

MemoryMetrics contains memory usage information

type MockKeyGenerator

type MockKeyGenerator struct {
	mock.Mock
}

MockKeyGenerator is a mock implementation of the KeyGenerator for testing

func NewMockKeyGenerator

func NewMockKeyGenerator() *MockKeyGenerator

NewMockKeyGenerator creates a new mock key generator

func (*MockKeyGenerator) DiagramKey

func (m *MockKeyGenerator) DiagramKey(diagramType models.DiagramType, name string) string

DiagramKey mocks the DiagramKey method

func (*MockKeyGenerator) EntityKey

func (m *MockKeyGenerator) EntityKey(umlVersion, diagramName, entityID string) string

EntityKey mocks the EntityKey method

func (*MockKeyGenerator) StateMachineKey

func (m *MockKeyGenerator) StateMachineKey(umlVersion, name string) string

StateMachineKey mocks the StateMachineKey method

func (*MockKeyGenerator) ValidateKey

func (m *MockKeyGenerator) ValidateKey(key string) error

ValidateKey mocks the ValidateKey method

type MockRedisClient

type MockRedisClient struct {
	mock.Mock
}

MockRedisClient is a mock implementation of the RedisClientInterface for testing

func NewMockRedisClient

func NewMockRedisClient() *MockRedisClient

NewMockRedisClient creates a new mock Redis client

func (*MockRedisClient) Client

func (m *MockRedisClient) Client() *redis.Client

Client mocks the Client method

func (*MockRedisClient) Close

func (m *MockRedisClient) Close() error

Close mocks the Close method

func (*MockRedisClient) Config

func (m *MockRedisClient) Config() *RedisConfig

Config mocks the Config method

func (*MockRedisClient) DBSize

func (m *MockRedisClient) DBSize(ctx context.Context) (int64, error)

DBSize mocks the DBSize method

func (*MockRedisClient) DBSizeWithRetry

func (m *MockRedisClient) DBSizeWithRetry(ctx context.Context) (int64, error)

DBSizeWithRetry mocks the DBSizeWithRetry method

func (*MockRedisClient) Del

func (m *MockRedisClient) Del(ctx context.Context, keys ...string) (int64, error)

Legacy methods for backward compatibility Del mocks the Del method

func (*MockRedisClient) DelBatchWithRetry

func (m *MockRedisClient) DelBatchWithRetry(ctx context.Context, keys ...string) (int64, error)

DelBatchWithRetry mocks the DelBatchWithRetry method

func (*MockRedisClient) DelWithRetry

func (m *MockRedisClient) DelWithRetry(ctx context.Context, keys ...string) error

DelWithRetry mocks the DelWithRetry method

func (*MockRedisClient) ExistsWithRetry

func (m *MockRedisClient) ExistsWithRetry(ctx context.Context, keys ...string) (int64, error)

ExistsWithRetry mocks the ExistsWithRetry method

func (*MockRedisClient) GetWithRetry

func (m *MockRedisClient) GetWithRetry(ctx context.Context, key string) (string, error)

GetWithRetry mocks the GetWithRetry method

func (*MockRedisClient) Health

func (m *MockRedisClient) Health(ctx context.Context) error

Health mocks the Health method

func (*MockRedisClient) HealthWithRetry

func (m *MockRedisClient) HealthWithRetry(ctx context.Context) error

HealthWithRetry mocks the HealthWithRetry method

func (*MockRedisClient) Info

func (m *MockRedisClient) Info(ctx context.Context, section string) (string, error)

Info mocks the Info method

func (*MockRedisClient) InfoWithRetry

func (m *MockRedisClient) InfoWithRetry(ctx context.Context, section string) (string, error)

InfoWithRetry mocks the InfoWithRetry method

func (*MockRedisClient) MemoryUsage

func (m *MockRedisClient) MemoryUsage(ctx context.Context, key string) (int64, error)

MemoryUsage mocks the MemoryUsage method

func (*MockRedisClient) MemoryUsageWithRetry

func (m *MockRedisClient) MemoryUsageWithRetry(ctx context.Context, key string) (int64, error)

MemoryUsageWithRetry mocks the MemoryUsageWithRetry method

func (*MockRedisClient) Scan

func (m *MockRedisClient) Scan(ctx context.Context, cursor uint64, match string, count int64) ([]string, uint64, error)

Scan mocks the Scan method

func (*MockRedisClient) ScanWithRetry

func (m *MockRedisClient) ScanWithRetry(ctx context.Context, cursor uint64, match string, count int64) ([]string, uint64, error)

ScanWithRetry mocks the ScanWithRetry method

func (*MockRedisClient) SetWithRetry

func (m *MockRedisClient) SetWithRetry(ctx context.Context, key string, value interface{}, expiration time.Duration) error

SetWithRetry mocks the SetWithRetry method

type NetworkCheck

type NetworkCheck struct {
	Reachable  bool          `json:"reachable"`        // Whether Redis server is reachable
	Latency    time.Duration `json:"latency"`          // Network latency
	PacketLoss float64       `json:"packet_loss"`      // Packet loss percentage
	Issues     []string      `json:"issues,omitempty"` // Network issues found
}

NetworkCheck contains network connectivity validation results

type OperationMetrics

type OperationMetrics struct {
	TotalCommands       int64   `json:"total_commands"`       // Total commands processed
	CommandsPerSecond   float64 `json:"commands_per_sec"`     // Commands per second
	ConnectedClients    int64   `json:"connected_clients"`    // Number of connected clients
	BlockedClients      int64   `json:"blocked_clients"`      // Number of blocked clients
	RejectedConnections int64   `json:"rejected_connections"` // Rejected connections
}

OperationMetrics contains operation statistics

type PerformanceCheck

type PerformanceCheck struct {
	Acceptable      bool     `json:"acceptable"`                // Whether performance is acceptable
	Bottlenecks     []string `json:"bottlenecks,omitempty"`     // Performance bottlenecks identified
	Recommendations []string `json:"recommendations,omitempty"` // Performance recommendations
}

PerformanceCheck contains performance validation results

type PerformanceMetrics

type PerformanceMetrics struct {
	MemoryUsage    MemoryMetrics    `json:"memory_usage"`    // Memory usage information
	KeyspaceInfo   KeyspaceMetrics  `json:"keyspace_info"`   // Keyspace statistics
	OperationStats OperationMetrics `json:"operation_stats"` // Operation statistics
	ServerInfo     ServerMetrics    `json:"server_info"`     // Server information
}

PerformanceMetrics contains performance-related metrics

type RedisCache

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

RedisCache implements the Cache interface using Redis as the backend

func NewRedisCache

func NewRedisCache(config *RedisConfig) (*RedisCache, error)

NewRedisCache creates a new Redis-backed cache implementation

func NewRedisCacheWithDependencies

func NewRedisCacheWithDependencies(client internal.RedisClientInterface, keyGen internal.KeyGenerator, config *RedisConfig) *RedisCache

NewRedisCacheWithDependencies creates a new Redis cache with injected dependencies for testing

func (*RedisCache) Cleanup

func (rc *RedisCache) Cleanup(ctx context.Context, pattern string) error

Cleanup removes cache entries matching a pattern with enhanced functionality

func (*RedisCache) CleanupWithOptions

func (rc *RedisCache) CleanupWithOptions(ctx context.Context, pattern string, options *CleanupOptions) (*CleanupResult, error)

CleanupWithOptions removes cache entries matching a pattern with configurable options

func (*RedisCache) Close

func (rc *RedisCache) Close() error

Close closes the cache connection

func (*RedisCache) DeleteDiagram

func (rc *RedisCache) DeleteDiagram(ctx context.Context, diagramType models.DiagramType, name string) error

DeleteDiagram removes a diagram from the cache for cleanup

func (*RedisCache) DeleteStateMachine

func (rc *RedisCache) DeleteStateMachine(ctx context.Context, umlVersion, name string) error

DeleteStateMachine removes a state machine from the cache with cascade deletion

func (*RedisCache) GetCacheSize

func (rc *RedisCache) GetCacheSize(ctx context.Context) (*CacheSizeInfo, error)

GetCacheSize returns information about cache size and memory usage

func (*RedisCache) GetConnectionHealth

func (rc *RedisCache) GetConnectionHealth(ctx context.Context) (*ConnectionHealth, error)

GetConnectionHealth returns detailed connection health information

func (*RedisCache) GetDiagram

func (rc *RedisCache) GetDiagram(ctx context.Context, diagramType models.DiagramType, name string) (string, error)

GetDiagram retrieves a PlantUML diagram with error handling

func (*RedisCache) GetEntity

func (rc *RedisCache) GetEntity(ctx context.Context, umlVersion, diagramName, entityID string) (interface{}, error)

GetEntity retrieves a state machine entity

func (*RedisCache) GetEntityAsRegion

func (rc *RedisCache) GetEntityAsRegion(ctx context.Context, umlVersion, diagramName, entityID string) (*models.Region, error)

GetEntityAsRegion retrieves a state machine entity and attempts to unmarshal it as a Region

func (*RedisCache) GetEntityAsState

func (rc *RedisCache) GetEntityAsState(ctx context.Context, umlVersion, diagramName, entityID string) (*models.State, error)

GetEntityAsState retrieves a state machine entity and attempts to unmarshal it as a State

func (*RedisCache) GetEntityAsTransition

func (rc *RedisCache) GetEntityAsTransition(ctx context.Context, umlVersion, diagramName, entityID string) (*models.Transition, error)

GetEntityAsTransition retrieves a state machine entity and attempts to unmarshal it as a Transition

func (*RedisCache) GetEntityAsVertex

func (rc *RedisCache) GetEntityAsVertex(ctx context.Context, umlVersion, diagramName, entityID string) (*models.Vertex, error)

GetEntityAsVertex retrieves a state machine entity and attempts to unmarshal it as a Vertex

func (*RedisCache) GetPerformanceMetrics

func (rc *RedisCache) GetPerformanceMetrics(ctx context.Context) (*PerformanceMetrics, error)

GetPerformanceMetrics returns detailed performance metrics

func (*RedisCache) GetStateMachine

func (rc *RedisCache) GetStateMachine(ctx context.Context, umlVersion, name string) (*models.StateMachine, error)

GetStateMachine retrieves a parsed state machine

func (*RedisCache) Health

func (rc *RedisCache) Health(ctx context.Context) error

Health performs a basic health check on the cache

func (*RedisCache) HealthDetailed

func (rc *RedisCache) HealthDetailed(ctx context.Context) (*HealthStatus, error)

HealthDetailed performs a comprehensive health check and returns detailed status information

func (*RedisCache) RunDiagnostics

func (rc *RedisCache) RunDiagnostics(ctx context.Context) (*DiagnosticInfo, error)

RunDiagnostics performs comprehensive diagnostic checks

func (*RedisCache) StoreDiagram

func (rc *RedisCache) StoreDiagram(ctx context.Context, diagramType models.DiagramType, name string, diagContent string, ttl time.Duration) error

StoreDiagram stores a PlantUML diagram with TTL support

func (*RedisCache) StoreEntity

func (rc *RedisCache) StoreEntity(ctx context.Context, umlVersion, diagramName, entityID string, entity interface{}, ttl time.Duration) error

StoreEntity stores a state machine entity with TTL support

func (*RedisCache) StoreStateMachine

func (rc *RedisCache) StoreStateMachine(ctx context.Context, umlVersion string, diagramType models.DiagramType, name string, machine *models.StateMachine, ttl time.Duration) error

StoreStateMachine stores a parsed state machine with TTL support and creates entity cache paths

func (*RedisCache) UpdateStateMachineEntityMapping

func (rc *RedisCache) UpdateStateMachineEntityMapping(ctx context.Context, umlVersion, name string, entityID, entityKey string, operation string) error

UpdateStateMachineEntityMapping updates the Entities mapping in a stored state machine This ensures referential integrity when entities are added or removed independently

type RedisConfig

type RedisConfig = internal.Config

Configuration types for external use

func DefaultRedisConfig

func DefaultRedisConfig() *RedisConfig

type RedisRetryConfig

type RedisRetryConfig = internal.RetryConfig

func DefaultRedisRetryConfig

func DefaultRedisRetryConfig() *RedisRetryConfig

type ServerMetrics

type ServerMetrics struct {
	RedisVersion    string `json:"redis_version"`    // Redis server version
	UptimeSeconds   int64  `json:"uptime_seconds"`   // Server uptime in seconds
	UptimeDays      int64  `json:"uptime_days"`      // Server uptime in days
	ServerMode      string `json:"server_mode"`      // Server mode (standalone, sentinel, cluster)
	Role            string `json:"role"`             // Server role (master, slave)
	ConnectedSlaves int64  `json:"connected_slaves"` // Number of connected slaves
}

ServerMetrics contains server information

Jump to

Keyboard shortcuts

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