cache

package
v0.0.0-...-424292f Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2018 License: BSD-3-Clause Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Key

func Key(args ...string) string

Key make a key as expected

func NewWriteCloser

func NewWriteCloser(store Store, key string, ttl int) io.WriteCloser

NewWriteCloser returns a write closer

Types

type PubSub

type PubSub interface {
	Unsubscribe(channels ...string) error
}

PubSub represents a subscriber

type RedisStore

type RedisStore struct {
	Client *redis.Client
	// contains filtered or unexported fields
}

RedisStore a redis client and a default ttl

func NewRedisStore

func NewRedisStore(host, password string, ttl int) (*RedisStore, error)

NewRedisStore initiate a new redisStore

func (*RedisStore) Delete

func (s *RedisStore) Delete(key string)

Delete a key in redis

func (*RedisStore) DeleteAll

func (s *RedisStore) DeleteAll(pattern string)

DeleteAll delete all mathing keys in redis

func (*RedisStore) Dequeue

func (s *RedisStore) Dequeue(queueName string, value interface{})

Dequeue gets from queue This is blocking while there is nothing in the queue

func (*RedisStore) DequeueWithContext

func (s *RedisStore) DequeueWithContext(c context.Context, queueName string, value interface{})

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{})

Enqueue pushes to queue

func (*RedisStore) Get

func (s *RedisStore) Get(key string, value interface{}) bool

Get a key from redis

func (*RedisStore) GetMessageFromSubscription

func (s *RedisStore) GetMessageFromSubscription(c context.Context, pb PubSub) (string, error)

GetMessageFromSubscription from a redis PubSub

func (*RedisStore) Lock

func (s *RedisStore) Lock(key string, expiration time.Duration, retrywdMillisecond int, retryCount int) bool

func (*RedisStore) Publish

func (s *RedisStore) Publish(channel string, value interface{})

Publish a msg in a channel

func (*RedisStore) QueueLen

func (s *RedisStore) QueueLen(queueName string) int

QueueLen returns the length of a queue

func (*RedisStore) RemoveFromQueue

func (s *RedisStore) RemoveFromQueue(rootKey string, memberKey string)

RemoveFromQueue removes a member from a list

func (*RedisStore) Set

func (s *RedisStore) Set(key string, value interface{})

Set a value in redis

func (*RedisStore) SetAdd

func (s *RedisStore) SetAdd(rootKey string, memberKey string, member interface{})

SetAdd add a member (identified by a key) in the cached set

func (*RedisStore) SetCard

func (s *RedisStore) SetCard(key string) int

SetCard returns the cardinality of a ZSet

func (*RedisStore) SetRemove

func (s *RedisStore) SetRemove(rootKey string, memberKey string, member interface{})

SetRemove removes a member from a set

func (*RedisStore) SetScan

func (s *RedisStore) SetScan(key string, members ...interface{}) error

SetScan scans a ZSet

func (*RedisStore) SetWithTTL

func (s *RedisStore) SetWithTTL(key string, value interface{}, ttl int)

SetWithTTL a value in local store (0 for eternity)

func (*RedisStore) Status

func (s *RedisStore) Status() sdk.MonitoringStatusLine

Status returns the status of the local cache

func (*RedisStore) Subscribe

func (s *RedisStore) Subscribe(channel string) PubSub

Subscribe to a channel

func (*RedisStore) Unlock

func (s *RedisStore) Unlock(key string)

func (*RedisStore) UpdateTTL

func (s *RedisStore) UpdateTTL(key string, ttl int)

UpdateTTL update the ttl linked to the key

type Store

type Store interface {
	Get(key string, value interface{}) bool
	Set(key string, value interface{})
	SetWithTTL(key string, value interface{}, ttl int)
	UpdateTTL(key string, ttl int)
	Delete(key string)
	DeleteAll(key string)
	Enqueue(queueName string, value interface{})
	Dequeue(queueName string, value interface{})
	DequeueWithContext(c context.Context, queueName string, value interface{})
	QueueLen(queueName string) int
	RemoveFromQueue(queueName string, memberKey string)
	Publish(queueName string, value interface{})
	Subscribe(queueName string) PubSub
	GetMessageFromSubscription(c context.Context, pb PubSub) (string, error)
	Status() sdk.MonitoringStatusLine
	SetAdd(rootKey string, memberKey string, member interface{})
	SetRemove(rootKey string, memberKey string, member interface{})
	SetCard(key string) int
	SetScan(key string, members ...interface{}) error
	Lock(key string, expiration time.Duration, retryWaitDurationMillisecond int, retryCount int) bool
	Unlock(key string)
}

Store is an interface

func New

func New(redisHost, redisPassword string, TTL int) (Store, error)

New init a cache

Jump to

Keyboard shortcuts

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