redis

package
v0.0.0-...-e6fe8c5 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2016 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is an instance that stores a Redis client that will be used to communicate with the Redis server.

func New

func New(client redis.Conn) *Cache

New creates a new instance of Cache.

func (*Cache) Add

func (c *Cache) Add(key string, value []byte, ttl int64) error

Add an item to the cache. If the item is already cached, the value won't be overwritten.

ttl defines the number of seconds the value should be cached. If ttl is 0, the item will be cached infinitely.

func (*Cache) CompareAndReplace

func (c *Cache) CompareAndReplace(token, key string, value []byte, ttl int64) error

CompareAndReplace validates the token with the token in the store. If the tokens match, we will replace the value and return true. If it doesn't, we will not replace the value and return false.

func (*Cache) Decrement

func (c *Cache) Decrement(key string, initial, offset, ttl int64) error

Decrement subtracts a value of offset to the initial value. If the initial value is already set, it will be added to the value currently stored in the cache.

func (*Cache) Delete

func (c *Cache) Delete(key string) error

Delete will validate if the key actually is stored in the cache. If it is stored, it will remove the item from the cache. If it is not stored, it will return false.

func (*Cache) DeleteMulti

func (c *Cache) DeleteMulti(keys []string) map[string]error

DeleteMulti will delete multiple values at a time. It uses the `Delete` method internally to do so. It will return a map of results to see if the deletion is successful.

func (*Cache) Flush

func (c *Cache) Flush() error

Flush will remove all the items from the hash.

func (*Cache) Get

func (c *Cache) Get(key string) ([]byte, string, error)

Get gets the value out of the map associated with the provided key.

func (*Cache) GetMulti

func (c *Cache) GetMulti(keys []string) (map[string][]byte, map[string]string, map[string]error)

GetMulti gets multiple values from the cache and returns them as a map. It uses `Get` internally to retrieve the data.

func (*Cache) Increment

func (c *Cache) Increment(key string, initial, offset, ttl int64) error

Increment adds a value of offset to the initial value. If the initial value is already set, it will be added to the value currently stored in the cache.

func (*Cache) Replace

func (c *Cache) Replace(key string, value []byte, ttl int64) error

Replace will update and only update the value of a cache key. If the key is not previously used, we will return false.

func (*Cache) Set

func (c *Cache) Set(key string, value []byte, ttl int64) error

Set sets the value of an item, regardless of wether or not the value is already cached.

ttl defines the number of seconds the value should be cached. If ttl is 0, the item will be cached infinitely.

func (*Cache) SetMulti

func (c *Cache) SetMulti(items map[string][]byte, ttl int64) map[string]error

SetMulti sets multiple values for their respective keys. This is a shorthand to use `Set` multiple times.

func (*Cache) Touch

func (c *Cache) Touch(key string, ttl int64) error

Touch will update the key's ttl to the given ttl value without altering the value.

Jump to

Keyboard shortcuts

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