123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- package redis
- import (
- "errors"
- "time"
- )
- type Error string
- func (err Error) Error() string { return string(err) }
- type Conn interface {
-
- Close() error
-
- Err() error
-
- Do(commandName string, args ...interface{}) (reply interface{}, err error)
-
- Send(commandName string, args ...interface{}) error
-
- Flush() error
-
- Receive() (reply interface{}, err error)
- }
- type Argument interface {
-
-
-
- RedisArg() interface{}
- }
- type Scanner interface {
-
-
-
-
-
- RedisScan(src interface{}) error
- }
- type ConnWithTimeout interface {
- Conn
-
-
-
- DoWithTimeout(timeout time.Duration, commandName string, args ...interface{}) (reply interface{}, err error)
-
-
- ReceiveWithTimeout(timeout time.Duration) (reply interface{}, err error)
- }
- var errTimeoutNotSupported = errors.New("redis: connection does not support ConnWithTimeout")
- func DoWithTimeout(c Conn, timeout time.Duration, cmd string, args ...interface{}) (interface{}, error) {
- cwt, ok := c.(ConnWithTimeout)
- if !ok {
- return nil, errTimeoutNotSupported
- }
- return cwt.DoWithTimeout(timeout, cmd, args...)
- }
- func ReceiveWithTimeout(c Conn, timeout time.Duration) (interface{}, error) {
- cwt, ok := c.(ConnWithTimeout)
- if !ok {
- return nil, errTimeoutNotSupported
- }
- return cwt.ReceiveWithTimeout(timeout)
- }
|