Documentation ¶
Index ¶
- Variables
- func ConnectToRedis(host, port, db, password string) (*redis.Client, error)
- type Service
- func (s *Service) Exists(ctx context.Context, key string) (bool, error)
- func (s *Service) Get(ctx context.Context, key string) ([]byte, error)
- func (s *Service) Set(ctx context.Context, ttl time.Duration, key string, val interface{}) error
- func (s *Service) SetJSON(ctx context.Context, ttl time.Duration, key string, val []byte) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrRedisKeyNotFound = errors.New("redis key not found")
ErrRedisKeyNotFound indicates that the cached element does not exist.
Functions ¶
func ConnectToRedis ¶
ConnectToRedis instantiates a new go-redis client.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a wrapper around go-redis for easy read and write
func (*Service) Exists ¶ added in v0.2.0
Exists returns true if the given key exists in redis.
ctx should have a timeout
key is the key that is being used to store the data
func (*Service) Set ¶
Set writes the given value to redis as json with the given TTL.
ctx should have a timeout
ttl is the time until the data should expire
key is the key that is being used to store the data
value can be any value
Click to show internal directories.
Click to hide internal directories.