Documentation ¶
Index ¶
- type GoRedisCacheProvider
- func (grc *GoRedisCacheProvider) CheckRedisReachable() error
- func (grc *GoRedisCacheProvider) Get(key string, t reflect.Type) (interface{}, bool)
- func (grc *GoRedisCacheProvider) Invalidate(key string, t reflect.Type) bool
- func (grc *GoRedisCacheProvider) Shutdown()
- func (grc *GoRedisCacheProvider) Update(key string, t reflect.Type, value interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GoRedisCacheProvider ¶
type GoRedisCacheProvider struct {
// contains filtered or unexported fields
}
GoRedisCacheProvider is a cache provider that allows to store cache entries in Redis. It uses a basic go-redis redis.Client to communicate with Redis.
func New ¶
func New(cacheDsn string, lifetime time.Duration) (*GoRedisCacheProvider, error)
New creates a new cache with the specified defaultLifetime (in seconds) and given redis DSN.
func (*GoRedisCacheProvider) CheckRedisReachable ¶
func (grc *GoRedisCacheProvider) CheckRedisReachable() error
CheckRedisReachable checks if the configured Redis instance is reachable by sending a ping command.
func (*GoRedisCacheProvider) Get ¶
func (grc *GoRedisCacheProvider) Get(key string, t reflect.Type) (interface{}, bool)
Get an Item from the cache, if there is a valid one. The function will return nil if there is no valid cache entry. A valid cache entry is present when:
- for the given type and key an item can be found.
- the found items defaultLifetime is not exceeded
func (*GoRedisCacheProvider) Invalidate ¶
func (grc *GoRedisCacheProvider) Invalidate(key string, t reflect.Type) bool
Invalidate manually invalidates the cache item behind the supplied key, if there is a cache item.
func (*GoRedisCacheProvider) Shutdown ¶
func (grc *GoRedisCacheProvider) Shutdown()
Shutdown closes the Redis client attached to the cache instance.