Documentation
¶
Index ¶
- type CacheManager
- func (cm *CacheManager) Close() error
- func (cm *CacheManager) Delete(ctx context.Context, key string) error
- func (cm *CacheManager) DeleteMultiple(ctx context.Context, keys []string) error
- func (cm *CacheManager) DeleteMultipleWithProvider(ctx context.Context, providerName string, keys []string) error
- func (cm *CacheManager) DeleteWithProvider(ctx context.Context, providerName string, key string) error
- func (cm *CacheManager) Exists(ctx context.Context, key string) (bool, error)
- func (cm *CacheManager) ExistsWithProvider(ctx context.Context, providerName string, key string) (bool, error)
- func (cm *CacheManager) Flush(ctx context.Context) error
- func (cm *CacheManager) Get(ctx context.Context, key string, dest interface{}) error
- func (cm *CacheManager) GetDefaultProvider() (CacheProvider, error)
- func (cm *CacheManager) GetKeys(ctx context.Context, pattern string) ([]string, error)
- func (cm *CacheManager) GetKeysWithProvider(ctx context.Context, providerName string, pattern string) ([]string, error)
- func (cm *CacheManager) GetMultiple(ctx context.Context, keys []string) (map[string]interface{}, error)
- func (cm *CacheManager) GetMultipleWithProvider(ctx context.Context, providerName string, keys []string) (map[string]interface{}, error)
- func (cm *CacheManager) GetProvider(name string) (CacheProvider, error)
- func (cm *CacheManager) GetProviderInfo() map[string]*types.ProviderInfo
- func (cm *CacheManager) GetStats(ctx context.Context) (map[string]*types.CacheStats, error)
- func (cm *CacheManager) GetTTL(ctx context.Context, key string) (time.Duration, error)
- func (cm *CacheManager) GetTTLWithProvider(ctx context.Context, providerName string, key string) (time.Duration, error)
- func (cm *CacheManager) GetWithProvider(ctx context.Context, providerName string, key string, dest interface{}) error
- func (cm *CacheManager) InvalidateByTag(ctx context.Context, tag string) error
- func (cm *CacheManager) InvalidateByTagWithProvider(ctx context.Context, providerName string, tag string) error
- func (cm *CacheManager) ListProviders() []string
- func (cm *CacheManager) RegisterProvider(provider CacheProvider) error
- func (cm *CacheManager) Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error
- func (cm *CacheManager) SetMultiple(ctx context.Context, items map[string]interface{}, ttl time.Duration) error
- func (cm *CacheManager) SetMultipleWithProvider(ctx context.Context, providerName string, items map[string]interface{}, ...) error
- func (cm *CacheManager) SetTTL(ctx context.Context, key string, ttl time.Duration) error
- func (cm *CacheManager) SetTTLWithProvider(ctx context.Context, providerName string, key string, ttl time.Duration) error
- func (cm *CacheManager) SetWithProvider(ctx context.Context, providerName string, key string, value interface{}, ...) error
- func (cm *CacheManager) SetWithTags(ctx context.Context, key string, value interface{}, ttl time.Duration, ...) error
- func (cm *CacheManager) SetWithTagsAndProvider(ctx context.Context, providerName string, key string, value interface{}, ...) error
- type CacheProvider
- type ManagerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheManager ¶
type CacheManager struct {
// contains filtered or unexported fields
}
CacheManager manages multiple cache providers
func NewCacheManager ¶
func NewCacheManager(config *ManagerConfig, logger *logrus.Logger) *CacheManager
NewCacheManager creates a new cache manager
func (*CacheManager) Delete ¶
func (cm *CacheManager) Delete(ctx context.Context, key string) error
Delete removes a value from the cache using the default provider
func (*CacheManager) DeleteMultiple ¶
func (cm *CacheManager) DeleteMultiple(ctx context.Context, keys []string) error
DeleteMultiple removes multiple values from the cache
func (*CacheManager) DeleteMultipleWithProvider ¶
func (cm *CacheManager) DeleteMultipleWithProvider(ctx context.Context, providerName string, keys []string) error
DeleteMultipleWithProvider removes multiple values using a specific provider
func (*CacheManager) DeleteWithProvider ¶
func (cm *CacheManager) DeleteWithProvider(ctx context.Context, providerName string, key string) error
DeleteWithProvider removes a value from the cache using a specific provider
func (*CacheManager) ExistsWithProvider ¶
func (cm *CacheManager) ExistsWithProvider(ctx context.Context, providerName string, key string) (bool, error)
ExistsWithProvider checks if a key exists in the cache using a specific provider
func (*CacheManager) Flush ¶
func (cm *CacheManager) Flush(ctx context.Context) error
Flush clears all cache data from all providers
func (*CacheManager) Get ¶
func (cm *CacheManager) Get(ctx context.Context, key string, dest interface{}) error
Get retrieves a value from the cache using the default provider
func (*CacheManager) GetDefaultProvider ¶
func (cm *CacheManager) GetDefaultProvider() (CacheProvider, error)
GetDefaultProvider returns the default provider
func (*CacheManager) GetKeysWithProvider ¶
func (cm *CacheManager) GetKeysWithProvider(ctx context.Context, providerName string, pattern string) ([]string, error)
GetKeysWithProvider returns keys matching a pattern using a specific provider
func (*CacheManager) GetMultiple ¶
func (cm *CacheManager) GetMultiple(ctx context.Context, keys []string) (map[string]interface{}, error)
GetMultiple retrieves multiple values from the cache
func (*CacheManager) GetMultipleWithProvider ¶
func (cm *CacheManager) GetMultipleWithProvider(ctx context.Context, providerName string, keys []string) (map[string]interface{}, error)
GetMultipleWithProvider retrieves multiple values using a specific provider
func (*CacheManager) GetProvider ¶
func (cm *CacheManager) GetProvider(name string) (CacheProvider, error)
GetProvider returns a specific provider by name
func (*CacheManager) GetProviderInfo ¶
func (cm *CacheManager) GetProviderInfo() map[string]*types.ProviderInfo
GetProviderInfo returns information about all registered providers
func (*CacheManager) GetStats ¶
func (cm *CacheManager) GetStats(ctx context.Context) (map[string]*types.CacheStats, error)
GetStats returns cache statistics from all providers
func (*CacheManager) GetTTLWithProvider ¶
func (cm *CacheManager) GetTTLWithProvider(ctx context.Context, providerName string, key string) (time.Duration, error)
GetTTLWithProvider returns the TTL of a key using a specific provider
func (*CacheManager) GetWithProvider ¶
func (cm *CacheManager) GetWithProvider(ctx context.Context, providerName string, key string, dest interface{}) error
GetWithProvider retrieves a value from the cache using a specific provider
func (*CacheManager) InvalidateByTag ¶
func (cm *CacheManager) InvalidateByTag(ctx context.Context, tag string) error
InvalidateByTag invalidates all keys with a specific tag
func (*CacheManager) InvalidateByTagWithProvider ¶
func (cm *CacheManager) InvalidateByTagWithProvider(ctx context.Context, providerName string, tag string) error
InvalidateByTagWithProvider invalidates all keys with a specific tag using a specific provider
func (*CacheManager) ListProviders ¶
func (cm *CacheManager) ListProviders() []string
ListProviders returns a list of registered provider names
func (*CacheManager) RegisterProvider ¶
func (cm *CacheManager) RegisterProvider(provider CacheProvider) error
RegisterProvider registers a cache provider
func (*CacheManager) Set ¶
func (cm *CacheManager) Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error
Set stores a value in the cache using the default provider
func (*CacheManager) SetMultiple ¶
func (cm *CacheManager) SetMultiple(ctx context.Context, items map[string]interface{}, ttl time.Duration) error
SetMultiple stores multiple values in the cache
func (*CacheManager) SetMultipleWithProvider ¶
func (cm *CacheManager) SetMultipleWithProvider(ctx context.Context, providerName string, items map[string]interface{}, ttl time.Duration) error
SetMultipleWithProvider stores multiple values using a specific provider
func (*CacheManager) SetTTLWithProvider ¶
func (cm *CacheManager) SetTTLWithProvider(ctx context.Context, providerName string, key string, ttl time.Duration) error
SetTTLWithProvider sets the TTL of a key using a specific provider
func (*CacheManager) SetWithProvider ¶
func (cm *CacheManager) SetWithProvider(ctx context.Context, providerName string, key string, value interface{}, ttl time.Duration) error
SetWithProvider stores a value in the cache using a specific provider
func (*CacheManager) SetWithTags ¶
func (cm *CacheManager) SetWithTags(ctx context.Context, key string, value interface{}, ttl time.Duration, tags []string) error
SetWithTags stores a value with tags for easier invalidation
type CacheProvider ¶
type CacheProvider interface {
// Provider information
GetName() string
GetSupportedFeatures() []types.CacheFeature
GetConnectionInfo() *types.ConnectionInfo
// Connection management
Connect(ctx context.Context) error
Disconnect(ctx context.Context) error
Ping(ctx context.Context) error
IsConnected() bool
// Basic cache operations
Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error
Get(ctx context.Context, key string, dest interface{}) error
Delete(ctx context.Context, key string) error
Exists(ctx context.Context, key string) (bool, error)
// Advanced operations
SetWithTags(ctx context.Context, key string, value interface{}, ttl time.Duration, tags []string) error
InvalidateByTag(ctx context.Context, tag string) error
GetStats(ctx context.Context) (*types.CacheStats, error)
Flush(ctx context.Context) error
// Batch operations
SetMultiple(ctx context.Context, items map[string]interface{}, ttl time.Duration) error
GetMultiple(ctx context.Context, keys []string) (map[string]interface{}, error)
DeleteMultiple(ctx context.Context, keys []string) error
// Key management
GetKeys(ctx context.Context, pattern string) ([]string, error)
GetTTL(ctx context.Context, key string) (time.Duration, error)
SetTTL(ctx context.Context, key string, ttl time.Duration) error
}
CacheProvider interface for cache backends
type ManagerConfig ¶
type ManagerConfig struct {
DefaultProvider string `json:"default_provider"`
RetryAttempts int `json:"retry_attempts"`
RetryDelay time.Duration `json:"retry_delay"`
Timeout time.Duration `json:"timeout"`
FallbackEnabled bool `json:"fallback_enabled"`
Metadata map[string]string `json:"metadata"`
}
ManagerConfig holds cache manager configuration