cache

package
v0.0.0-...-56e218b Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2018 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

IronCache (cloud k/v store) client library

Index

Constants

This section is empty.

Variables

View Source
var (
	JSON = Codec{Marshal: json.Marshal, Unmarshal: json.Unmarshal}
	Gob  = Codec{Marshal: gobMarshal, Unmarshal: gobUnmarshal}
)

Functions

This section is empty.

Types

type Cache

type Cache struct {
	Settings config.Settings
	Name     string
}

func New

func New(cacheName string) *Cache

New returns a struct ready to make requests with. The cacheName argument is used as namespace.

func (*Cache) Add

func (c *Cache) Add(key string, value ...interface{}) (err error)

func (*Cache) Clear

func (c *Cache) Clear() (err error)

func (*Cache) Delete

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

Delete removes an item from the cache.

func (*Cache) Get

func (c *Cache) Get(key string) (value interface{}, err error)

Get gets an item from the cache.

func (*Cache) GetMeta

func (c *Cache) GetMeta(key string) (value map[string]interface{}, err error)

func (*Cache) Increment

func (c *Cache) Increment(key string, amount int64) (value interface{}, err error)

Increment increments the corresponding item's value.

func (*Cache) ListCaches

func (c *Cache) ListCaches(page, perPage int) (caches []*Cache, err error)

func (*Cache) Put

func (c *Cache) Put(key string, item *Item) (err error)

Put adds an Item to the cache, overwriting any existing key of the same name.

func (*Cache) Replace

func (c *Cache) Replace(key string, value ...interface{}) (err error)

func (*Cache) ServerVersion

func (c *Cache) ServerVersion() (version string, err error)

func (*Cache) Set

func (c *Cache) Set(key string, value interface{}, ttl ...int) (err error)

type Codec

type Codec struct {
	Marshal   func(interface{}) ([]byte, error)
	Unmarshal func([]byte, interface{}) error
}

func (Codec) Get

func (cd Codec) Get(c *Cache, key string, object interface{}) (err error)

func (Codec) Put

func (cd Codec) Put(c *Cache, key string, item *Item) (err error)

type Item

type Item struct {
	// Value is the Item's value
	Value interface{}
	// Object is the Item's value for use with a Codec.
	Object interface{}
	// Number of seconds until expiration. The zero value defaults to 7 days,
	// maximum is 30 days.
	Expiration time.Duration
	// Caches item only if the key is currently cached.
	Replace bool
	// Caches item only if the key isn't currently cached.
	Add bool
}

Jump to

Keyboard shortcuts

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