Documentation ¶
Index ¶
- type RedisConfig
- type Service
- func (r *Service) AllExist(keys ...string) (bool, error)
- func (r *Service) Close() error
- func (r *Service) Delete(key string) error
- func (r *Service) Exists(key string) (bool, error)
- func (r *Service) Expire(key string, newSecondsLifeTime int64) error
- func (r *Service) Expires(seconds int64, keys ...string) error
- func (r *Service) Get(key interface{}) (interface{}, error)
- func (r *Service) GetAll() (interface{}, error)
- func (r *Service) GetBytes(key string) ([]byte, error)
- func (r *Service) GetJson(key string, out interface{}) error
- func (r *Service) GetMap(key string) (map[string]interface{}, error)
- func (r *Service) HGet(key, field string, result interface{}) error
- func (r *Service) HGetAsMap(key, field string) (map[string]interface{}, error)
- func (r *Service) HMGet(key string, result interface{}, fields ...string) error
- func (r *Service) HMGetAll(key string, result interface{}) error
- func (r *Service) HMSet(key string, kvs map[string]interface{}, secondsLifetime int64) error
- func (r *Service) HSet(key, field string, value interface{}, secondsLifetime int64) (err error)
- func (r *Service) LGet(key string, index int, value interface{}) error
- func (r *Service) LGetAll(key string, result interface{}) error
- func (r *Service) LLen(key string) (int, error)
- func (r *Service) LSet(key string, objs interface{}, secondsLifetime int64) error
- func (r *Service) PingPong() (bool, error)
- func (r *Service) Publish(channel string, msg interface{}) (int, error)
- func (r *Service) Set(key interface{}, value interface{}, seconds int) error
- func (r *Service) SetJson(key string, value interface{}, secondsLifetime int64) (err error)
- func (r *Service) Subscribe(channel string) (*redis.PubSubConn, error)
- func (r *Service) TTL(key string) (seconds int64, hasExpiration bool, found bool)
- type ServiceFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RedisConfig ¶
type RedisConfig struct { // Network "tcp" Network string // Addr "127.0.0.1:6379" Addr string // Password string .If no password then no 'AUTH'. Default "" Password string // If Database is empty "" then no 'SELECT'. Default "" Database string // MaxIdle 0 no limit MaxIdle int // MaxActive 0 no limit MaxActive int // IdleTimeout time.Duration(5) * time.Minute IdleTimeout time.Duration }
var ( ErrRedisClosed an error with message 'Redis is already closed' ErrRedisClosed = errors.New("Redis is already closed") ErrKeyNotFound an error with message 'Key $thekey doesn't found' ErrKeyNotFound = errors.New("Key '%s' doesn't found") )
type Service ¶
type Service struct { // // Connected is true when the Service has already connected // Connected bool // // Config the redis config for this redis Redis redis.Conn }
Service the Redis service, contains the config and the redis Pool
func NewService ¶
func (*Service) GetBytes ¶
GetBytes returns value, err by its key you can use utils.Deserialize((.GetBytes("yourkey"),&theobject{}) returns nil and a filled error if something wrong happens
func (*Service) PingPong ¶
PingPong sends a ping and receives a pong, if no pong received then returns false and filled error
func (*Service) Set ¶
Get returns value, err by its key returns nil and a filled error if something bad happened.
type ServiceFactory ¶
type ServiceFactory struct { Config *RedisConfig Pool *redis.Pool }
var MainRedis *ServiceFactory
func NewFactory ¶
func NewFactory(Config *RedisConfig) *ServiceFactory
func (*ServiceFactory) Get ¶
func (s *ServiceFactory) Get() *Service