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(keys ...string) ([]interface{}, error)
- func (rc *RedisClient) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
- type RedisConfig
Constants ¶
View Source
const ( // Consul constant for getting ConsulClient from Cache factory Consul = "consul" // Redis constant for getting Redis cache client Redis = "redis" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Driver string ConsulConfig ConsulConfig RedisConfig RedisConfig }
Config holds cache configuration
type ConsulClient ¶
type ConsulClient struct {
// contains filtered or unexported fields
}
ConsulClient ...
func (*ConsulClient) Delete ¶
func (c *ConsulClient) Delete(ctx context.Context, key string) error
Delete deletes a single key from consul.
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) }
ICache is an interface for implementing cache.
func NewConsulClient ¶
func NewConsulClient(config *ConsulConfig) (ICache, error)
NewConsulClient creates a new consul client
type RedisClient ¶
type RedisClient struct {
// contains filtered or unexported fields
}
RedisClient ...
func NewRedisClient ¶
func NewRedisClient(config *RedisConfig) (*RedisClient, error)
NewRedisClient ...
func (*RedisClient) Delete ¶
func (rc *RedisClient) Delete(ctx context.Context, key string) error
Delete ...
func (*RedisClient) Disconnect ¶
func (rc *RedisClient) Disconnect() error
Disconnect ... disconnects from the redis server
func (*RedisClient) IsAlive ¶
func (rc *RedisClient) IsAlive(ctx context.Context) (bool, error)
IsAlive ...
func (*RedisClient) MGet ¶
func (rc *RedisClient) MGet(keys ...string) ([]interface{}, error)
MGet ...
Click to show internal directories.
Click to hide internal directories.