Documentation ¶
Index ¶
- Constants
- type Config
- type ConsulClient
- func (c *ConsulClient) Delete(ctx context.Context, key string) error
- func (c *ConsulClient) Get(ctx context.Context, key string) ([]byte, error)
- func (c *ConsulClient) IsAlive(context.Context) (bool, error)
- func (c *ConsulClient) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
- type ConsulConfig
- type ICache
- type RedisClient
- func (rc *RedisClient) Delete(ctx context.Context, key string) error
- func (rc *RedisClient) Disconnect() error
- func (rc *RedisClient) Get(ctx context.Context, key string) ([]byte, error)
- func (rc *RedisClient) IsAlive(ctx context.Context) (bool, error)
- func (rc *RedisClient) MGet(ctx context.Context, keys ...string) ([]any, error)
- func (rc *RedisClient) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
- type RedisConfig
- type RedisOption
Constants ¶
View Source
const ( Consul = "consul" Redis = "redis" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Provider string RedisConfig RedisConfig ConsulConfig ConsulConfig }
type ConsulClient ¶
type ConsulClient struct {
// contains filtered or unexported fields
}
type ConsulConfig ¶
type ICache ¶
type ICache interface { // Get a key from cache. Get(ctx context.Context, key string) ([]byte, error) // Set a key in cache. Set(ctx context.Context, key string, value []byte, ttl time.Duration) error // Delete a key in cache. Delete(ctx context.Context, key string) error // IsAlive performs a healthcheck on the cache. IsAlive(context.Context) (bool, error) }
func NewConsulClient ¶
func NewConsulClient(config *ConsulConfig) (ICache, error)
func NewRedisClient ¶
func NewRedisClient(config *RedisConfig, opts ...RedisOption) (ICache, error)
type RedisClient ¶
type RedisClient struct {
// contains filtered or unexported fields
}
func (*RedisClient) Disconnect ¶
func (rc *RedisClient) Disconnect() error
type RedisConfig ¶
type RedisOption ¶
type RedisOption func(*RedisClient)
func WithReadTimeout ¶
func WithReadTimeout(t time.Duration) RedisOption
WithReadTimeout set read timeout
func WithWriteTimeout ¶
func WithWriteTimeout(t time.Duration) RedisOption
WithWriteTimeout set write timeout
Click to show internal directories.
Click to hide internal directories.