service

package
v3.0.0-rc.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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")
)

Functions

This section is empty.

Types

type Service

type Service struct {
	// Connected is true when the Service has already connected
	Connected bool
	// Config the redis config for this redis
	Config *config.Redis
	// contains filtered or unexported fields
}

Service the Redis service, contains the config and the redis pool

func New

func New(cfg ...config.Redis) *Service

New returns a Redis service filled by the passed config to connect call the .Connect()

func (*Service) CloseConnection

func (r *Service) CloseConnection() error

CloseConnection closes the redis connection

func (*Service) Connect

func (r *Service) Connect()

Connect connects to the redis, called only once

func (*Service) Delete

func (r *Service) Delete(key string) error

Delete removes redis entry by specific key

func (*Service) Get

func (r *Service) Get(key string) (interface{}, error)

Get returns value, err by its key you can use utils.Deserialize((.Get("yourkey"),&theobject{}) returns nil and a filled error if something wrong happens

func (*Service) GetAll

func (r *Service) GetAll(key string) (map[string]string, error)

GetAll returns all keys and their values from a specific key (map[string]string) returns a filled error if something bad happened

func (*Service) GetAllKeysByPrefix

func (r *Service) GetAllKeysByPrefix(prefix string) ([]string, error)

GetAllKeysByPrefix returns all []string keys by a key prefix from the redis

func (*Service) GetBytes

func (r *Service) GetBytes(key string) ([]byte, error)

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) GetInt

func (r *Service) GetInt(key string) (int, error)

GetInt returns value, err by its key you can use utils.Deserialize((.GetInt("yourkey"),&theobject{}) returns -1 int and a filled error if something wrong happens

func (*Service) GetString

func (r *Service) GetString(key string) (string, error)

GetString returns value, err by its key you can use utils.Deserialize((.GetString("yourkey"),&theobject{}) returns empty string and a filled error if something wrong happens

func (*Service) GetStringMap

func (r *Service) GetStringMap(key string) (map[string]string, error)

GetStringMap returns map[string]string, err by its key returns nil and a filled error if something wrong happens

func (*Service) PingPong

func (r *Service) PingPong() (bool, error)

PingPong sends a ping and receives a pong, if no pong received then returns false and filled error

func (*Service) Set

func (r *Service) Set(key string, value []byte, maxageseconds ...float64) (err error)

Set sets to the redis key string, value string, you can use utils.Serialize(&myobject{}) to convert an object to []byte

Jump to

Keyboard shortcuts

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