Documentation ¶
Index ¶
- Constants
- Variables
- type InMemoryStore
- func (s *InMemoryStore) Exists(key string) (bool, error)
- func (s *InMemoryStore) Get(key string) (string, error)
- func (s *InMemoryStore) Publish(topic string, data []byte) error
- func (s *InMemoryStore) Remove(key string) error
- func (s *InMemoryStore) Set(key string, value string, expire int64) error
- func (s *InMemoryStore) Subscribe(channel string, callback func(notifier.Notification)) error
- type Options
- type RedisStore
- func (s *RedisStore) Exists(key string) (bool, error)
- func (s *RedisStore) Get(key string) (string, error)
- func (s *RedisStore) Publish(topic string, data []byte) error
- func (s *RedisStore) Remove(key string) error
- func (s *RedisStore) Set(key string, value string, expire int64) error
- func (s *RedisStore) Subscribe(channel string, callback func(notifier.Notification)) error
- type Store
Constants ¶
const ( // InMemory storage InMemory = "memory" // Redis storage Redis = "redis" // None Nullable storage None = "none" )
Variables ¶
var ( // ErrUnknownStorage is used when the storage type is nknown ErrUnknownStorage = errors.New(http.StatusBadRequest, "Unknown storage type") )
Functions ¶
This section is empty.
Types ¶
type InMemoryStore ¶
InMemoryStore is the redis store.
func NewInMemoryStore ¶
func NewInMemoryStore() *InMemoryStore
NewInMemoryStore returns an instance of memory store.
func NewInMemoryStoreWithOptions ¶
func NewInMemoryStoreWithOptions() *InMemoryStore
NewInMemoryStoreWithOptions returns an instance of memory store with custom options.
func (*InMemoryStore) Exists ¶
func (s *InMemoryStore) Exists(key string) (bool, error)
Exists checks if a key exists in the store
func (*InMemoryStore) Get ¶
func (s *InMemoryStore) Get(key string) (string, error)
Get retreives a value from the store
func (*InMemoryStore) Publish ¶
func (s *InMemoryStore) Publish(topic string, data []byte) error
Publish publishes in memory
func (*InMemoryStore) Remove ¶
func (s *InMemoryStore) Remove(key string) error
Remove a value from the store
func (*InMemoryStore) Set ¶
func (s *InMemoryStore) Set(key string, value string, expire int64) error
Set a value in the store
func (*InMemoryStore) Subscribe ¶
func (s *InMemoryStore) Subscribe(channel string, callback func(notifier.Notification)) error
Subscribe subscribes to messages in memory
type Options ¶
type Options struct { // Prefix is the prefix to use for the key. Prefix string // MaxRetry is the maximum number of retry under race conditions. MaxRetry int // CleanUpInterval is the interval for cleanup. CleanUpInterval time.Duration }
Options are options for store.
type RedisStore ¶
type RedisStore struct { // The prefix to use for the key. Prefix string // go-redis Client instance Client *redis.Client // The maximum number of retry under race conditions. MaxRetry int }
RedisStore is the redis store.
func (*RedisStore) Exists ¶
func (s *RedisStore) Exists(key string) (bool, error)
Exists checks if a key exists in the store
func (*RedisStore) Get ¶
func (s *RedisStore) Get(key string) (string, error)
Get retreives a value from the store
func (*RedisStore) Publish ¶
func (s *RedisStore) Publish(topic string, data []byte) error
Publish publishes to a topic in redis
func (*RedisStore) Remove ¶
func (s *RedisStore) Remove(key string) error
Remove a value from the store
func (*RedisStore) Set ¶
func (s *RedisStore) Set(key string, value string, expire int64) error
Set a value in the store
func (*RedisStore) Subscribe ¶
func (s *RedisStore) Subscribe(channel string, callback func(notifier.Notification)) error
Subscribe subscribes to a topic in redis
type Store ¶
type Store interface { Exists(key string) (bool, error) Get(key string) (string, error) Remove(key string) error Set(key string, value string, expire int64) error }
Store is the common interface for datastores.
func NewRedisStore ¶
NewRedisStore returns an instance of redis store.