cacheservice

package
v2.1.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2017 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCacheService string

DefaultCacheService decides the default cache service connection.

Functions

func Register

func Register(name string, fn NewConnFunc)

Register a db connection.

Types

type CacheService

type CacheService interface {
	// Get returns cached data for given keys.
	Get(keys ...string) (results []Result, err error)
	// Gets returns cached data for given keys, it is an alternative Get api
	// for using with CAS. Gets returns a CAS identifier with the item. If
	// the item's CAS value has changed since you Gets'ed it, it will not be stored.
	Gets(keys ...string) (results []Result, err error)
	// Set set the value with specified cache key.
	Set(key string, flags uint16, timeout uint64, value []byte) (stored bool, err error)
	// Add store the value only if it does not already exist.
	Add(key string, flags uint16, timeout uint64, value []byte) (stored bool, err error)
	// Replace replaces the value, only if the value already exists,
	// for the specified cache key.
	Replace(key string, flags uint16, timeout uint64, value []byte) (stored bool, err error)
	// Append appends the value after the last bytes in an existing item.
	Append(key string, flags uint16, timeout uint64, value []byte) (stored bool, err error)
	// Prepend prepends the value before existing value.
	Prepend(key string, flags uint16, timeout uint64, value []byte) (stored bool, err error)
	// Cas stores the value only if no one else has updated the data since you read it last.
	Cas(key string, flags uint16, timeout uint64, value []byte, cas uint64) (stored bool, err error)
	// Delete delete the value for the specified cache key.
	Delete(key string) (deleted bool, err error)
	// FlushAll purges the entire cache.
	FlushAll() (err error)
	// Stats returns a list of basic stats.
	Stats(argument string) (result []byte, err error)
	// Close closes the CacheService
	Close()
}

CacheService defines functions to use a cache service.

func Connect

func Connect(config Config) (CacheService, error)

Connect returns a CacheService using the given config.

type Config

type Config struct {
	Address string
	Timeout time.Duration
}

Config carries config data for CacheService.

type NewConnFunc

type NewConnFunc func(config Config) (CacheService, error)

NewConnFunc is a factory method that creates a CacheService instance using given CacheServiceConfig.

type Result

type Result struct {
	Key   string
	Value []byte
	Flags uint16
	Cas   uint64
}

Result gives the cached data.

Jump to

Keyboard shortcuts

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