2019-08-06 17:40:13 +02:00
|
|
|
package redis
|
|
|
|
|
2020-10-04 15:50:21 +02:00
|
|
|
import "time"
|
|
|
|
|
2019-08-06 17:40:13 +02:00
|
|
|
// Driver is the interface which each supported redis client
|
|
|
|
// should support in order to be used in the redis session database.
|
|
|
|
type Driver interface {
|
|
|
|
Connect(c Config) error
|
|
|
|
PingPong() (bool, error)
|
|
|
|
CloseConnection() error
|
2020-10-04 15:50:21 +02:00
|
|
|
Set(sid, key string, value interface{}) error
|
|
|
|
Get(sid, key string) (interface{}, error)
|
|
|
|
Exists(sid string) bool
|
|
|
|
TTL(sid string) time.Duration
|
|
|
|
UpdateTTL(sid string, newLifetime time.Duration) error
|
|
|
|
GetAll(sid string) (map[string]string, error)
|
|
|
|
GetKeys(sid string) ([]string, error)
|
|
|
|
Len(sid string) int
|
|
|
|
Delete(sid, key string) error
|
2019-08-06 17:40:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
2020-10-04 15:50:21 +02:00
|
|
|
_ Driver = (*GoRedisDriver)(nil)
|
2019-08-06 17:40:13 +02:00
|
|
|
)
|
|
|
|
|
2020-10-04 15:50:21 +02:00
|
|
|
// GoRedis returns the default Driver for the redis sessions database
|
|
|
|
// It's the go-redis client. Learn more at: https://github.com/go-redis/redis.
|
|
|
|
func GoRedis() *GoRedisDriver {
|
|
|
|
return &GoRedisDriver{}
|
2019-08-06 17:40:13 +02:00
|
|
|
}
|