redisc

package
v0.0.0-...-0e65dd1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2015 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayOfBytes

func ArrayOfBytes(results interface{}, err error) ([][]byte, error)

func ArrayOfInts

func ArrayOfInts(results interface{}, err error) ([]int, error)

func ArrayOfStrings

func ArrayOfStrings(results interface{}, err error) ([]string, error)

func GetMembers

func GetMembers(members []*ScoredMember) []string

func Prefix

func Prefix(namespace string, keys []string) []string

func PrefixStringsToInterfaces

func PrefixStringsToInterfaces(prefix string, keys []string) []interface{}

func ReadWriteHosts

func ReadWriteHosts(hosts []*RedisHosts) (read []string, write []string)

func StringsToInterfaces

func StringsToInterfaces(keys []string) []interface{}

Types

type Client

type Client interface {
	StringsCache
	SortedSet
	Set
	Write(command string, args ...interface{}) (interface{}, error)
	Read(command string, args ...interface{}) (interface{}, error)
}

type KeyValueString

type KeyValueString struct {
	Key   string
	Value string
}

type RedisCache

type RedisCache struct {
	Log     logging.Logger `inject:""`
	Encoder func(v interface{}) ([]byte, error)
	Decoder func(data []byte, v interface{}) error
	// contains filtered or unexported fields
}

func NewService

func NewService(readUris []string, writeUris []string, hostPassword string) *RedisCache

NewRedisCache creates a new cache service connecting to the given hostUris and hostPassword. If there is no hostPassword, then pass an empty string.

func (*RedisCache) Get

func (r *RedisCache) Get(key string) (value string, err error)

Get value from cache by key.

func (*RedisCache) GetBytes

func (r *RedisCache) GetBytes(key string) (result []byte, err error)

func (*RedisCache) GetHashInt64

func (r *RedisCache) GetHashInt64(hashName string) (map[string]int64, error)

func (*RedisCache) GetObject

func (r *RedisCache) GetObject(key string, instance interface{}) (miss bool, err error)

func (*RedisCache) Increment

func (r *RedisCache) Increment(hashName, fieldName string, by int) (int64, error)

func (*RedisCache) MGet

func (r *RedisCache) MGet(keys []string) (result []string, err error)

func (*RedisCache) MSet

func (r *RedisCache) MSet(kv []*KeyValueString) error

func (*RedisCache) Ping

func (r *RedisCache) Ping() error

func (*RedisCache) Read

func (r *RedisCache) Read(command string, args ...interface{}) (interface{}, error)

func (*RedisCache) ReadInt64

func (r *RedisCache) ReadInt64(command string, args ...interface{}) (int64, error)

func (*RedisCache) SAdd

func (rc *RedisCache) SAdd(key string, items ...string) (int, error)

SAdd returns the number of items added to the set from the items given.

func (*RedisCache) SMembers

func (s *RedisCache) SMembers(listKey string) ([]string, error)

func (*RedisCache) SRandMember

func (rc *RedisCache) SRandMember(key string, count int) ([]string, error)

func (*RedisCache) SRem

func (rc *RedisCache) SRem(key string, items ...string) (int, error)

SRem returns the number items removed from the set

func (*RedisCache) Set

func (r *RedisCache) Set(key string, value string) error

func (*RedisCache) SetAdd

func (rc *RedisCache) SetAdd(key string, items []interface{}) (int, error)

SAdd returns the number of items added to the set from the items given.

func (*RedisCache) SetBytes

func (r *RedisCache) SetBytes(key string, bytes []byte) error

func (*RedisCache) SetNX

func (r *RedisCache) SetNX(key string, value string) error

func (*RedisCache) SetRemove

func (s *RedisCache) SetRemove(listKey string, member []byte) (int, error)

func (*RedisCache) Write

func (r *RedisCache) Write(command string, args ...interface{}) (interface{}, error)

func (*RedisCache) ZAdd

func (rc *RedisCache) ZAdd(key string, members ...*ScoredMember) (int, error)

func (*RedisCache) ZCard

func (rc *RedisCache) ZCard(key string) (int, error)

ZCard returns the Cardinality (i.e. count) of the set

func (*RedisCache) ZIncrBy

func (rc *RedisCache) ZIncrBy(key string, amount int, member string) (int, error)

func (*RedisCache) ZRevRange

func (rc *RedisCache) ZRevRange(key string, start, stop int) ([]*ScoredMember, error)

ZRevRange returns a subset ordered in descending order

func (*RedisCache) ZRevRangeByScore

func (rc *RedisCache) ZRevRangeByScore(key string, max, min int) ([]*ScoredMember, error)

func (*RedisCache) ZScore

func (rc *RedisCache) ZScore(key, member string) (*int, error)

type RedisHosts

type RedisHosts struct {
	Host    string `json:"host"`
	Primary bool   `json:"primary"`
}

type RedisSortedSetMock

type RedisSortedSetMock struct {
	ZAddArgs      []*ZAddArgs
	ZRevRangeArgs []*ZRevRangeArgs
	ZIncrByArgs   []*ZIncrByArgs
	ZCardArgs     []*ZCardArgs
}

func NewRedisSortedSetMock

func NewRedisSortedSetMock() *RedisSortedSetMock

func (*RedisSortedSetMock) ZAdd

func (m *RedisSortedSetMock) ZAdd(key string, members []*ScoredMember) (int, error)

func (*RedisSortedSetMock) ZCard

func (m *RedisSortedSetMock) ZCard(key string) (int, error)

ZCard returns the Cardinality (i.e. count) of the set

func (*RedisSortedSetMock) ZIncrBy

func (m *RedisSortedSetMock) ZIncrBy(key string, amount int, member []byte) (int, error)

func (*RedisSortedSetMock) ZRevRange

func (m *RedisSortedSetMock) ZRevRange(key string, start, stop int) ([]*ScoredMember, error)

ZRevRange returns a subset ordered in descending order

func (*RedisSortedSetMock) ZRevRangeByScore

func (rc *RedisSortedSetMock) ZRevRangeByScore(key string, max, min int) ([]*ScoredMember, error)

type ScoredMember

type ScoredMember struct {
	Score  int
	Member string
}

type Set

type Set interface {
	// Add
	SAdd(key string, items ...string) (int, error)
	// Remove
	SRem(key string, items ...string) (int, error)

	SRandMember(key string, count int) ([]string, error)

	SMembers(listKey string) ([]string, error)
}

type SetP

type SetP struct {
	Key   string
	Value string
	TTL   time.Duration
	NX    bool
	XX    bool
}

func (*SetP) Command

func (s *SetP) Command() (string, []interface{})

type SortedSet

type SortedSet interface {
	ZAdd(key string, members ...*ScoredMember) (int, error)

	// ZRevRange returns a subset ordered in descending order
	ZRevRange(key string, start, stop int) ([]*ScoredMember, error)
	ZRevRangeByScore(key string, max, min int) ([]*ScoredMember, error)

	ZIncrBy(key string, amount int, member string) (int, error)

	// ZCard returns the Cardinality (i.e. count) of the set
	ZCard(key string) (int, error)

	// ZSScore if the member or key does not exists return a nil int with no error
	ZScore(key, member string) (*int, error)
}

type StringsCache

type StringsCache interface {
	Get(key string) (value string, err error)
	Set(key string, value string) error
	SetNX(key string, value string) error
	MGet(keys []string) (result []string, err error)
	MSet(kv []*KeyValueString) error
}

type ZAddArgs

type ZAddArgs struct {
	Key     string
	Members []*ScoredMember
}

type ZCardArgs

type ZCardArgs struct {
	Key string
}

type ZIncrByArgs

type ZIncrByArgs struct {
	Key    string
	Amount int
	Member []byte
}

type ZRevRangeArgs

type ZRevRangeArgs struct {
	Key         string
	Start, Stop int
}

Jump to

Keyboard shortcuts

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