Documentation ¶
Index ¶
- type Connection
- func (conn Connection) Close() error
- func (conn Connection) DeleteCache(key string) error
- func (conn Connection) DeleteCacheContext(c context.Context, key string) error
- func (conn Connection) Exists(key string) bool
- func (conn Connection) ExistsContext(c context.Context, key string) bool
- func (conn Connection) GetCache(key string, val interface{}) error
- func (conn Connection) GetCacheContext(c context.Context, key string, val interface{}) error
- func (conn Connection) Publish(channel string, message interface{}) error
- func (conn Connection) PublishContext(c context.Context, channel string, message interface{}) error
- func (conn Connection) SetCache(key string, val interface{}, override bool) error
- func (conn Connection) SetCacheContext(c context.Context, key string, val interface{}, override bool) error
- func (conn Connection) SetCacheTTLContext(c context.Context, key string, val interface{}, override bool, ...) error
- func (conn Connection) Subscribe(channels ...string) *redis.PubSub
- func (conn Connection) SubscribeContext(c context.Context, channels ...string) *redis.PubSub
- type Options
- func (o *Options) SetAddr(addr string) *Options
- func (o *Options) SetDB(db int) *Options
- func (o *Options) SetDialTimeout(dialTimeout time.Duration) *Options
- func (o *Options) SetIdleTimeout(idleTimeout time.Duration) *Options
- func (o *Options) SetMaxRetries(maxRetries int) *Options
- func (o *Options) SetPassword(password string) *Options
- func (o *Options) SetPoolFIFO(poolFIFO bool) *Options
- func (o *Options) SetPoolTimeout(poolTimeout time.Duration) *Options
- func (o *Options) SetReadTimeout(readTimeout time.Duration) *Options
- func (o *Options) SetTLSConfig(tlsConfig *tls.Config) *Options
- func (o *Options) SetUsername(username string) *Options
- func (o *Options) SetWriteTimeout(writeTimeout time.Duration) *Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct { Client *redis.Client Cache *cache.Cache }
func (Connection) DeleteCache ¶
func (conn Connection) DeleteCache(key string) error
DeleteCache deletes a redis item
func (Connection) DeleteCacheContext ¶
func (conn Connection) DeleteCacheContext(c context.Context, key string) error
DeleteCacheContext deletes a redis item with context
func (Connection) Exists ¶
func (conn Connection) Exists(key string) bool
Exists checks if a key exists
func (Connection) ExistsContext ¶
func (conn Connection) ExistsContext(c context.Context, key string) bool
ExistsContext checks if a key exists with context
func (Connection) GetCache ¶
func (conn Connection) GetCache(key string, val interface{}) error
GetCache gets a redis item
func (Connection) GetCacheContext ¶
func (conn Connection) GetCacheContext(c context.Context, key string, val interface{}) error
GetCacheContext gets a redis item with context
func (Connection) Publish ¶
func (conn Connection) Publish(channel string, message interface{}) error
Publish publishes a message to a channel
func (Connection) PublishContext ¶
func (conn Connection) PublishContext(c context.Context, channel string, message interface{}) error
PublishContext publishes a message to a channel with context
func (Connection) SetCache ¶
func (conn Connection) SetCache(key string, val interface{}, override bool) error
SetCache sets a redis with one hour TTL
func (Connection) SetCacheContext ¶
func (conn Connection) SetCacheContext(c context.Context, key string, val interface{}, override bool) error
SetCacheContext sets a redis with one hour TTL with context
func (Connection) SetCacheTTLContext ¶
func (conn Connection) SetCacheTTLContext(c context.Context, key string, val interface{}, override bool, ttl time.Duration) error
SetCacheTTLContext sets a redis with a TTL
func (Connection) Subscribe ¶
func (conn Connection) Subscribe(channels ...string) *redis.PubSub
Subscribe subscribes to a channel
Example 1:
for { msg, err := pubsub.ReceiveMessage(ctx) if err != nil { panic(err) } fmt.Println(msg.Channel, msg.Payload) }
Example 2: ch := pubsub.Channel()
for msg := range ch { fmt.Println(msg.Channel, msg.Payload) }
func (Connection) SubscribeContext ¶
func (conn Connection) SubscribeContext(c context.Context, channels ...string) *redis.PubSub
SubscribeContext subscribes to a channel with context
type Options ¶
type Options struct { Addr string Username string Password string DB int MaxRetries int DialTimeout time.Duration ReadTimeout time.Duration WriteTimeout time.Duration PoolTimeout time.Duration IdleTimeout time.Duration PoolFIFO bool TLSConfig *tls.Config }
func (*Options) SetDialTimeout ¶
func (*Options) SetIdleTimeout ¶
func (*Options) SetPoolTimeout ¶
func (*Options) SetReadTimeout ¶
Click to show internal directories.
Click to hide internal directories.