redis

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

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:

  1. for the given type and key an item can be found.
  2. 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.

func (*GoRedisCacheProvider) Update

func (grc *GoRedisCacheProvider) Update(key string, t reflect.Type, value interface{}) error

Update adds and item to the cache or updates it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL