Documentation
¶
Overview ¶
Package cache provides persistent file-based caching for tenant configuration.
The FileCache component enables the tenant Provider to degrade gracefully when ETCD is unavailable by maintaining a local copy of tenant data.
Features:
- Atomic writes using temporary file + rename
- JSON encoding for human-readable cache files
- Configurable cache path via TENANT_CACHE_PATH env variable
- Thread-safe operations with mutex protection
Usage:
cache := cache.NewFileCache()
data, err := cache.Load()
if err == nil {
// Use cached data as fallback
}
cache.Save(tenantData) // Persist on ETCD updates
Package cache provides persistent cache layer for tenant data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Codec ¶
type Codec interface {
Encode(data interface{}) ([]byte, error)
Decode(bytes []byte, dest interface{}) error
}
Codec defines the encoding/decoding interface for cache data.
type FileCache ¶
type FileCache struct {
// contains filtered or unexported fields
}
FileCache provides persistent file-based caching for tenant data.
func NewFileCache ¶
func NewFileCache() *FileCache
NewFileCache creates a new file-based cache. The cache path can be configured via TENANT_CACHE_PATH env variable. Default path: ./cache/tenant_metadata.json
func NewFileCacheWithPath ¶
NewFileCacheWithPath creates a cache with a specific file path.
func (*FileCache) IsAvailable ¶
IsAvailable checks if the cache file exists and is readable.