Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheService ¶
type CacheService interface { Set(ctx context.Context, key string, value any, expiration time.Duration) *redis.StatusCmd Get(ctx context.Context, key string) *redis.StringCmd FlushAll(ctx context.Context) *redis.StatusCmd Del(ctx context.Context, keys ...string) *redis.IntCmd Close() error }
CacheService combines methods of redis client and redis clustered client to have one impl that works for both, reduced to only what we use
func NewRedisCacheService ¶
func NewRedisCacheService(clustered bool, redisSettings Settings) CacheService
NewRedisCacheService establishes connection to Redis and creates client. db is the 0-16 db instance to use from redis. tls is whether redis server uses tls - false if eg. running in docker but may be true if in production. url is the redis server url.
type Settings ¶
type Settings struct { // URL eg. localhost:6379 URL string `yaml:"URL"` Password string `yaml:"PASSWORD"` // TLS enable tls TLS bool `yaml:"TLS"` // KeyPrefix prepends this string to all keys. Makes it easier with many services sharing redis cluster. If empty no prefix. KeyPrefix string `yaml:"KEY_PREFIX"` }
Settings add these redis settings to your settings struct
Click to show internal directories.
Click to hide internal directories.