cache

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2017 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Status string

Status : local ok redis

Functions

func Delete

func Delete(key string)

Delete something from the cache.

func DeleteAll

func DeleteAll(key string)

DeleteAll something from the cache.

func Dequeue

func Dequeue(queueName string, value interface{})

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

func Enqueue

func Enqueue(queueName string, value interface{})

Enqueue pushes to queue

func Get

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

Get something from the cache.

func Initialize

func Initialize(mode, redisHost, redisPassword string, TTL int)

Initialize the global cache in memory, or redis

func Key

func Key(args ...string) string

Key make a key as expected

func Set

func Set(key string, value interface{})

Set something from the cache.

func SetWithTTL

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

SetWithTTL something in the cache with a specific TTL.

Types

type LocalStore

type LocalStore struct {
	Mutex  *sync.Mutex
	Data   map[string][]byte
	Queues map[string]*list.List
	TTL    int
}

LocalStore is a in memory cache for dev purpose only

func (*LocalStore) Delete

func (s *LocalStore) Delete(key string)

Delete a key from local store

func (*LocalStore) DeleteAll

func (s *LocalStore) DeleteAll(key string)

DeleteAll on locastore delete all the things

func (*LocalStore) Dequeue

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

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

func (*LocalStore) Enqueue

func (s *LocalStore) Enqueue(queueName string, value interface{})

Enqueue pushes to queue

func (*LocalStore) Get

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

Get a key from local store

func (*LocalStore) Set

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

Set a value in local store

func (*LocalStore) SetWithTTL

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

SetWithTTL a value in local store with a specific ttl (in seconds): (0 for eternity)

type RedisStore

type RedisStore struct {
	Client redisClient
	// 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) 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) Set

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

Set a value in redis

func (*RedisStore) SetWithTTL

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

SetWithTTL a value in local store (0 for eternity)

type Store

type Store interface {
	Get(key string, value interface{}) bool
	Set(key string, value interface{})
	SetWithTTL(key string, value interface{}, ttl int)
	Delete(key string)
	DeleteAll(key string)
	Enqueue(queueName string, value interface{})
	Dequeue(queueName string, value interface{})
}

Store is an interface

Jump to

Keyboard shortcuts

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