Documentation ¶
Index ¶
- Constants
- func Key(args ...string) string
- func NewWriteCloser(store Store, key string, ttl int) io.WriteCloser
- type HealthStore
- type LockStore
- type PubSub
- type PubSubStore
- type QueueStore
- type RedisPubSub
- type RedisStore
- func (s *RedisStore) DBSize() (int64, error)
- func (s *RedisStore) Delete(key string) error
- func (s *RedisStore) DeleteAll(pattern string) error
- func (s *RedisStore) DequeueJSONRawMessagesWithContext(ctx context.Context, queueName string, waitDuration time.Duration, ...) ([]json.RawMessage, error)
- func (s *RedisStore) DequeueWithContext(c context.Context, queueName string, waitDuration time.Duration, ...) error
- func (s *RedisStore) Enqueue(queueName string, value interface{}) error
- func (s *RedisStore) Eval(expr string, args ...string) (string, error)
- func (s *RedisStore) Exist(key string) (bool, error)
- func (s *RedisStore) Get(key string, value interface{}) (bool, error)
- func (s *RedisStore) Keys(pattern string) ([]string, error)
- func (s *RedisStore) Lock(key string, expiration time.Duration, retrywdMillisecond int, retryCount int) (bool, error)
- func (s *RedisStore) Ping() error
- func (s *RedisStore) Publish(ctx context.Context, channel string, value interface{}) error
- func (s *RedisStore) QueueLen(queueName string) (int, error)
- func (s *RedisStore) RemoveFromQueue(rootKey string, memberKey string) error
- func (s *RedisStore) ScoredSetAdd(_ context.Context, key string, value interface{}, score float64) error
- func (s *RedisStore) ScoredSetAppend(ctx context.Context, key string, value interface{}) error
- func (s *RedisStore) ScoredSetGetScore(key string, member interface{}) (float64, error)
- func (s *RedisStore) ScoredSetRange(_ context.Context, key string, from, to int64, dest interface{}) error
- func (s *RedisStore) ScoredSetRem(_ context.Context, key string, members ...string) error
- func (s *RedisStore) ScoredSetRevRange(_ context.Context, key string, offset int64, limit int64, dest interface{}) error
- func (s *RedisStore) ScoredSetScan(_ context.Context, key string, from, to float64, dest interface{}) error
- func (s *RedisStore) ScoredSetScanMaxScore(_ context.Context, key string) (*SetValueWithScore, error)
- func (s *RedisStore) ScoredSetScanWithScores(_ context.Context, key string, from, to float64) ([]SetValueWithScore, error)
- func (s *RedisStore) Set(key string, value interface{}) error
- func (s *RedisStore) SetAdd(rootKey string, memberKey string, member interface{}) error
- func (s *RedisStore) SetCard(key string) (int, error)
- func (s *RedisStore) SetRemove(rootKey string, memberKey string, _ interface{}) error
- func (s *RedisStore) SetScan(ctx context.Context, key string, members ...interface{}) error
- func (s *RedisStore) SetSearch(key, pattern string) ([]string, error)
- func (s *RedisStore) SetWithDuration(key string, value interface{}, duration time.Duration) error
- func (s *RedisStore) SetWithTTL(key string, value interface{}, ttl int) error
- func (s *RedisStore) Size(key string) (int64, error)
- func (s *RedisStore) Subscribe(channel string) (PubSub, error)
- func (s *RedisStore) Unlock(key string) error
- func (s *RedisStore) UpdateTTL(key string, ttl int) error
- type ScoredSetStore
- type SetStore
- type SetValueWithScore
- type Store
Constants ¶
const ( MIN float64 = math.MaxFloat64 * -1 MAX float64 = math.MaxFloat64 )
Variables ¶
This section is empty.
Functions ¶
func NewWriteCloser ¶
func NewWriteCloser(store Store, key string, ttl int) io.WriteCloser
NewWriteCloser returns a write closer
Types ¶
type HealthStore ¶
type PubSub ¶
type PubSub interface { Unsubscribe(channels ...string) error GetMessage(c context.Context) (string, error) }
PubSub represents a subscriber
type PubSubStore ¶
type QueueStore ¶
type QueueStore interface { Enqueue(queueName string, value interface{}) error DequeueWithContext(c context.Context, queueName string, waitDuration time.Duration, value interface{}) error DequeueJSONRawMessagesWithContext(c context.Context, queueName string, waitDuration time.Duration, maxElements int) ([]json.RawMessage, error) QueueLen(queueName string) (int, error) RemoveFromQueue(queueName string, memberKey string) error }
type RedisPubSub ¶
func (*RedisPubSub) GetMessage ¶
func (p *RedisPubSub) GetMessage(ctx context.Context) (string, error)
type RedisStore ¶
RedisStore a redis client and a default ttl
func NewRedisStore ¶
func NewRedisStore(host, password string, dbindex, ttl int) (*RedisStore, error)
NewRedisStore initiate a new redisStore
func (*RedisStore) DBSize ¶
func (s *RedisStore) DBSize() (int64, error)
DBSize: Return the number of keys in the currently-selected database
func (*RedisStore) DeleteAll ¶
func (s *RedisStore) DeleteAll(pattern string) error
DeleteAll delete all mathing keys in redis
func (*RedisStore) DequeueJSONRawMessagesWithContext ¶
func (s *RedisStore) DequeueJSONRawMessagesWithContext(ctx context.Context, queueName string, waitDuration time.Duration, maxElements int) ([]json.RawMessage, error)
DequeueListWithContext gets from queue This is blocking while there is nothing in the queue, it can be cancelled with a context.Context
func (*RedisStore) DequeueWithContext ¶
func (s *RedisStore) DequeueWithContext(c context.Context, queueName string, waitDuration time.Duration, value interface{}) error
DequeueWithContext gets from queue This is blocking while there is nothing in the queue, it can be cancelled with a context.Context
func (*RedisStore) Enqueue ¶
func (s *RedisStore) Enqueue(queueName string, value interface{}) error
Enqueue pushes to queue
func (*RedisStore) Exist ¶
func (s *RedisStore) Exist(key string) (bool, error)
Exist test is key exists
func (*RedisStore) Get ¶
func (s *RedisStore) Get(key string, value interface{}) (bool, error)
Get a key from redis
func (*RedisStore) Ping ¶
func (s *RedisStore) Ping() error
func (*RedisStore) Publish ¶
func (s *RedisStore) Publish(ctx context.Context, channel string, value interface{}) error
Publish a msg in a channel
func (*RedisStore) QueueLen ¶
func (s *RedisStore) QueueLen(queueName string) (int, error)
QueueLen returns the length of a queue
func (*RedisStore) RemoveFromQueue ¶
func (s *RedisStore) RemoveFromQueue(rootKey string, memberKey string) error
RemoveFromQueue removes a member from a list
func (*RedisStore) ScoredSetAdd ¶
func (*RedisStore) ScoredSetAppend ¶
func (s *RedisStore) ScoredSetAppend(ctx context.Context, key string, value interface{}) error
func (*RedisStore) ScoredSetGetScore ¶
func (s *RedisStore) ScoredSetGetScore(key string, member interface{}) (float64, error)
func (*RedisStore) ScoredSetRange ¶
func (*RedisStore) ScoredSetRem ¶
func (*RedisStore) ScoredSetRevRange ¶
func (*RedisStore) ScoredSetScan ¶
func (*RedisStore) ScoredSetScanMaxScore ¶
func (s *RedisStore) ScoredSetScanMaxScore(_ context.Context, key string) (*SetValueWithScore, error)
func (*RedisStore) ScoredSetScanWithScores ¶
func (s *RedisStore) ScoredSetScanWithScores(_ context.Context, key string, from, to float64) ([]SetValueWithScore, error)
func (*RedisStore) Set ¶
func (s *RedisStore) Set(key string, value interface{}) error
Set a value in redis
func (*RedisStore) SetAdd ¶
func (s *RedisStore) SetAdd(rootKey string, memberKey string, member interface{}) error
SetAdd add a member (identified by a key) in the cached set
func (*RedisStore) SetCard ¶
func (s *RedisStore) SetCard(key string) (int, error)
SetCard returns the cardinality of a ZSet
func (*RedisStore) SetRemove ¶
func (s *RedisStore) SetRemove(rootKey string, memberKey string, _ interface{}) error
SetRemove removes a member from a set
func (*RedisStore) SetScan ¶
func (s *RedisStore) SetScan(ctx context.Context, key string, members ...interface{}) error
SetScan scans a ZSet
func (*RedisStore) SetSearch ¶
func (s *RedisStore) SetSearch(key, pattern string) ([]string, error)
func (*RedisStore) SetWithDuration ¶
func (s *RedisStore) SetWithDuration(key string, value interface{}, duration time.Duration) error
SetWithDuration a value in local store (0 for eternity)
func (*RedisStore) SetWithTTL ¶
func (s *RedisStore) SetWithTTL(key string, value interface{}, ttl int) error
SetWithTTL a value in local store (0 for eternity)
func (*RedisStore) Subscribe ¶
func (s *RedisStore) Subscribe(channel string) (PubSub, error)
Subscribe to a channel
func (*RedisStore) Unlock ¶
func (s *RedisStore) Unlock(key string) error
Unlock deletes a key from cache
type ScoredSetStore ¶
type ScoredSetStore interface { Delete(key string) error ScoredSetAdd(ctx context.Context, key string, value interface{}, score float64) error ScoredSetAppend(ctx context.Context, key string, value interface{}) error ScoredSetScan(ctx context.Context, key string, from, to float64, dest interface{}) error ScoredSetScanWithScores(ctx context.Context, key string, from, to float64) ([]SetValueWithScore, error) ScoredSetScanMaxScore(ctx context.Context, key string) (*SetValueWithScore, error) ScoredSetRange(ctx context.Context, key string, from, to int64, dest interface{}) error ScoredSetRevRange(_ context.Context, key string, offset int64, limit int64, dest interface{}) error ScoredSetRem(ctx context.Context, key string, members ...string) error ScoredSetGetScore(key string, member interface{}) (float64, error) SetCard(key string) (int, error) Eval(expr string, args ...string) (string, error) HealthStore }
type SetStore ¶
type SetStore interface { SetAdd(rootKey string, memberKey string, member interface{}) error SetRemove(rootKey string, memberKey string, member interface{}) error SetCard(key string) (int, error) SetScan(ctx context.Context, key string, members ...interface{}) error SetSearch(key, pattern string) ([]string, error) }
type SetValueWithScore ¶
type SetValueWithScore struct { Score float64 Value json.RawMessage }
type Store ¶
type Store interface { Get(key string, value interface{}) (bool, error) Set(key string, value interface{}) error SetWithTTL(key string, value interface{}, ttl int) error SetWithDuration(key string, value interface{}, duration time.Duration) error UpdateTTL(key string, ttl int) error Delete(key string) error DeleteAll(key string) error Exist(key string) (bool, error) Eval(expr string, args ...string) (string, error) HealthStore LockStore QueueStore PubSubStore ScoredSetStore SetStore }
Store is an interface