This page lists the constructor and RedisFallback methods of go-redis-fallback with their signatures, return values, and errors.
Constructor
New
func New(c Config) (*RedisFallback, error)
Item
Detail
Behavior
Applies defaults, initializes the logger and Redis client, and pings Redis: on success it runs the Recovery Resync synchronously, on failure it enters fallback and starts the health check; finally it starts the batch writer and the 30-second expiry sweep
Errors
Only a logger initialization failure; the message starts with Failed to initialize and wraps the cause with %w
Redis unreachable
Not an error; the instance is returned in fallback mode
Panics
When c.Redis is nil: inside New if the ping succeeds, otherwise on the first local file access (details)
The original value on a memory hit; the JSON-decoded result when restored from a local file; nil with a nil error when another instance stored a map or struct in Redis (details)
Error Not found
The key is missing or expired
Error Failed to parse
The local file is not valid JSON
Side effects
A normal-mode memory hit writes back to Redis in the background; a failed Redis read switches to fallback
Set
func (rf *RedisFallback) Set(key string, value interface{}, ttl time.Duration) error