Documentation
¶
Index ¶
- func AddCacheCommands(rootCmd *cobra.Command, manager *Manager)
- type CacheConfig
- type CacheInfo
- type CachedResponse
- type Manager
- func (m *Manager) BatchGet(keys []string) map[string]*CachedResponse
- func (m *Manager) ClearCache() error
- func (m *Manager) GenerateCacheKey(method, endpoint string) string
- func (m *Manager) Get(key string) (*CachedResponse, bool, error)
- func (m *Manager) ListCache() ([]CacheInfo, error)
- func (m *Manager) Remove(key string) error
- func (m *Manager) Set(key string, statusCode int, body []byte, headers map[string][]string) error
- type OfflineConfig
- func (c *OfflineConfig) ClearPendingOperations()
- func (c *OfflineConfig) GetPendingOperations() []Operation
- func (c *OfflineConfig) IsOnline() bool
- func (c *OfflineConfig) QueueOperation(method, endpoint string, payload []byte)
- func (c *OfflineConfig) SyncPendingOperations(client *http.Client) error
- type OfflineMode
- type Operation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCacheCommands ¶
AddCacheCommands adds cache-related commands to the root command
Types ¶
type CacheConfig ¶
type CacheConfig struct {
MaxSize int64 // Maximum size in bytes
MaxEntries int // Maximum number of entries
TTL time.Duration // Time-to-live for cache entries
}
CacheConfig holds configuration for the cache manager
type CachedResponse ¶
type CachedResponse struct {
StatusCode int `json:"status_code"`
Body []byte `json:"body"`
Headers map[string][]string `json:"headers"`
CachedAt time.Time `json:"cached_at"`
ExpiresAt time.Time `json:"expires_at"`
}
CachedResponse represents a cached HTTP response
type Manager ¶
type Manager struct {
OfflineConfig *OfflineConfig
// contains filtered or unexported fields
}
Manager handles caching operations
func NewManager ¶
func NewManager(config CacheConfig) (*Manager, error)
NewManager creates a new cache manager with configuration
func (*Manager) BatchGet ¶
func (m *Manager) BatchGet(keys []string) map[string]*CachedResponse
BatchGet retrieves multiple cached responses efficiently
func (*Manager) ClearCache ¶
ClearCache clears all cached items
func (*Manager) GenerateCacheKey ¶
GenerateCacheKey creates a unique key for caching
func (*Manager) Get ¶
func (m *Manager) Get(key string) (*CachedResponse, bool, error)
Get retrieves a cached response with LRU update
type OfflineConfig ¶
type OfflineConfig struct {
Mode OfflineMode `json:"mode"`
LastOnlineCheck time.Time `json:"last_online_check"`
NetworkTimeout time.Duration `json:"network_timeout"`
AutoSyncInterval time.Duration `json:"auto_sync_interval"`
PendingOperations []Operation `json:"pending_operations"`
// contains filtered or unexported fields
}
OfflineConfig stores offline operation settings
func (*OfflineConfig) ClearPendingOperations ¶
func (c *OfflineConfig) ClearPendingOperations()
ClearPendingOperations removes all queued operations
func (*OfflineConfig) GetPendingOperations ¶
func (c *OfflineConfig) GetPendingOperations() []Operation
GetPendingOperations returns all queued operations
func (*OfflineConfig) IsOnline ¶
func (c *OfflineConfig) IsOnline() bool
IsOnline checks if network connectivity is available
func (*OfflineConfig) QueueOperation ¶
func (c *OfflineConfig) QueueOperation(method, endpoint string, payload []byte)
QueueOperation adds an operation to be executed when online
func (*OfflineConfig) SyncPendingOperations ¶
func (c *OfflineConfig) SyncPendingOperations(client *http.Client) error
SyncPendingOperations attempts to execute queued operations
type OfflineMode ¶
type OfflineMode int
OfflineMode represents the offline operation mode
const ( // OnlineMode normal operation with network access OnlineMode OfflineMode = iota // AutoOfflineMode automatically switches to offline mode when network is unavailable AutoOfflineMode // StrictOfflineMode forces offline-only operation StrictOfflineMode )