Documentation ¶
Index ¶
- Constants
- Variables
- type Cache
- type Config
- type RedigoDriver
- func (r *RedigoDriver) CloseConnection() error
- func (r *RedigoDriver) Connect(c Config) error
- func (r *RedigoDriver) Get(key string) (interface{}, error)
- func (r *RedigoDriver) PingPong() (bool, error)
- func (r *RedigoDriver) Set(key string, value interface{}) (err error)
- func (r *RedigoDriver) SetEX(key string, value interface{}, expirationtime int64) (err error)
Constants ¶
View Source
const ( // DefaultPrefix = "" // DefaultDelim ths redis delim option, "-". DefaultDelim = "-" )
View Source
const ( // DefaultRedisNetwork the redis network option, "tcp". DefaultRedisNetwork = "tcp" // DefaultRedisAddr the redis address option, "127.0.0.1:6379". DefaultRedisAddr = "127.0.0.1:6379" // DefaultRedisTimeout the redis idle timeout option, time.Duration(30) * time.Second DefaultRedisTimeout = time.Duration(30) * time.Second )
Variables ¶
View Source
var ( // ErrRedisClosed an error with message 'redis: already closed' ErrRedisClosed = errors.New("redis: already closed") // ErrKeyNotFound a type of error of non-existing redis keys. // The producers(the library) of this error will dynamically wrap this error(fmt.Errorf) with the key name. // Usage: // if err != nil && errors.Is(err, ErrKeyNotFound) { // [...] // } ErrKeyNotFound = errors.New("key not found") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { // Driver *RedigoDriver // Prefix "myprefix-for-this-website". Defaults to "". Prefix string // Delim the delimeter for the keys on the sessiondb. Defaults to "-". Delim string // contains filtered or unexported fields }
func DefaultCache ¶
func DefaultCache() *Cache
type Config ¶
type Config struct { // Network protocol. Defaults to "tcp". Network string // Addr of a single redis server instance. // See "Clusters" field for clusters support. // Defaults to "127.0.0.1:6379". Addr string // Clusters a list of network addresses for clusters. // If not empty "Addr" is ignored. // Currently only Radix() Driver supports it. Clusters []string // Password string .If no password then no 'AUTH'. Defaults to "". Password string // If Database is empty "" then no 'SELECT'. Defaults to "". Database string // MaxActive. Defaults to 10. MaxActive int // Timeout for connect, write and read, defaults to 30 seconds, 0 means no timeout. Timeout time.Duration // TLSConfig will cause Dial to perform a TLS handshake using the provided // config. If is nil then no TLS is used. // See https://golang.org/pkg/crypto/tls/#Config TLSConfig *tls.Config }
Config the redis configuration used inside sessions
func DefaultConfig ¶
func DefaultConfig() Config
type RedigoDriver ¶
type RedigoDriver struct { // Maximum number of idle connections in the pool. MaxIdle int // Close connections after remaining idle for this duration. If the value // is zero, then idle connections are not closed. Applications should set // the timeout to a value less than the server's timeout. IdleTimeout time.Duration // If Wait is true and the pool is at the MaxActive limit, then Get() waits // for a connection to be returned to the pool before returning. Wait bool // Close connections older than this duration. If the value is zero, then // the pool does not close connections based on age. MaxConnLifetime time.Duration // contains filtered or unexported fields }
RedigoDriver is the redigo Redis go client, contains the config and the redis pool
func NewDriver ¶
func NewDriver(r ...RedigoDriver) *RedigoDriver
func (*RedigoDriver) CloseConnection ¶
func (r *RedigoDriver) CloseConnection() error
func (*RedigoDriver) Connect ¶
func (r *RedigoDriver) Connect(c Config) error
Connect connects to the redis, called only once.
func (*RedigoDriver) Get ¶
func (r *RedigoDriver) Get(key string) (interface{}, error)
Get returns value, err by its key returns nil and a filled error if something bad happened.
func (*RedigoDriver) PingPong ¶
func (r *RedigoDriver) PingPong() (bool, error)
PingPong sends a ping and receives a pong, if no pong received then returns false and filled error
func (*RedigoDriver) Set ¶
func (r *RedigoDriver) Set(key string, value interface{}) (err error)
Set sets a key-value to the redis store.
Click to show internal directories.
Click to hide internal directories.